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

Function check_code_string

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

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

Callers

nothing calls this directly

Calls 2

_configFunction · 0.85
check_streamFunction · 0.85

Tested by

no test coverage detected