MCPcopy Create free account
hub / github.com/PyCQA/isort / check_code_string

Function check_code_string

isort/api.py:106–135  ·  view source on GitHub ↗

Checks the order, format, and categorization of imports within the provided code string. Returns `True` if everything is correct, otherwise `False`. - **code**: The string of code with imports that need to be sorted. - **show_diff**: If `True` the changes that need to be done will be pr

(
    code: str,
    show_diff: bool | TextIO = False,
    extension: str | None = None,
    config: Config = DEFAULT_CONFIG,
    file_path: Path | None = None,
    disregard_skip: bool = False,
    **config_kwargs: Any,
)

Source from the content-addressed store, hash-verified

104
105
106def check_code_string(
107 code: str,
108 show_diff: bool | TextIO = False,
109 extension: str | None = None,
110 config: Config = DEFAULT_CONFIG,
111 file_path: Path | None = None,
112 disregard_skip: bool = False,
113 **config_kwargs: Any,
114) -> bool:
115 """Checks the order, format, and categorization of imports within the provided code string.
116 Returns `True` if everything is correct, otherwise `False`.
117
118 - **code**: The string of code with imports that need to be sorted.
119 - **show_diff**: If `True` the changes that need to be done will be printed to stdout, if a
120 TextIO stream is provided results will be written to it, otherwise no diff will be computed.
121 - **extension**: The file extension that contains imports. Defaults to filename extension or py.
122 - **config**: The config object to use when sorting imports.
123 - **file_path**: The disk location where the code string was pulled from.
124 - **disregard_skip**: set to `True` if you want to ignore a skip set in config for this file.
125 - ****config_kwargs**: Any config modifications.
126 """
127 config = _config(path=file_path, config=config, **config_kwargs)
128 return check_stream(
129 StringIO(code),
130 show_diff=show_diff,
131 extension=extension,
132 config=config,
133 file_path=file_path,
134 disregard_skip=disregard_skip,
135 )
136
137
138def sort_stream(

Callers

nothing calls this directly

Calls 2

_configFunction · 0.85
check_streamFunction · 0.85

Tested by

no test coverage detected