MCPcopy
hub / github.com/PyCQA/isort / check_code_string

Function check_code_string

isort/api.py:101–130  ·  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

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

Callers

nothing calls this directly

Calls 2

_configFunction · 0.85
check_streamFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…