Skip to content

Commit

Permalink
Rename _strip_syntax to strip_syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
bp72 committed Dec 9, 2023
1 parent 15e5bd1 commit a8fc20c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions isort/identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path
from typing import Iterator, NamedTuple, Optional, TextIO, Tuple

from isort.parse import _strip_syntax, normalize_line, skip_line
from isort.parse import normalize_line, skip_line, strip_syntax

from .comments import parse as parse_comments
from .settings import DEFAULT_CONFIG, Config
Expand Down Expand Up @@ -162,7 +162,7 @@ def imports(

just_imports = [
item.replace("{|", "{ ").replace("|}", " }")
for item in _strip_syntax(import_string).split()
for item in strip_syntax(import_string).split()
]

direct_imports = just_imports[1:]
Expand Down
14 changes: 7 additions & 7 deletions isort/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def import_type(line: str, config: Config = DEFAULT_CONFIG) -> Optional[str]:
return None


def _strip_syntax(import_string: str) -> str:
def strip_syntax(import_string: str) -> str:
import_string = import_string.replace("_import", "[[i]]")
import_string = import_string.replace("_cimport", "[[ci]]")
for remove_syntax in ["\\", "(", ")", ","]:
Expand Down Expand Up @@ -276,7 +276,7 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte
nested_comments = {}
import_string, comment = parse_comments(line)
comments = [comment] if comment else []
line_parts = [part for part in _strip_syntax(import_string).strip().split(" ") if part]
line_parts = [part for part in strip_syntax(import_string).strip().split(" ") if part]
if type_of_import == "from" and len(line_parts) == 2 and comments:
nested_comments[line_parts[-1]] = comments[0]

Expand All @@ -286,7 +286,7 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte
index += 1
if new_comment:
comments.append(new_comment)
stripped_line = _strip_syntax(line).strip()
stripped_line = strip_syntax(line).strip()
if (
type_of_import == "from"
and stripped_line
Expand All @@ -310,7 +310,7 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte
and ")" not in line.split("#")[0]
and index < line_count
):
stripped_line = _strip_syntax(line).strip()
stripped_line = strip_syntax(line).strip()
if (
type_of_import == "from"
and stripped_line
Expand All @@ -326,7 +326,7 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte
index += 1
if new_comment:
comments.append(new_comment)
stripped_line = _strip_syntax(line).strip()
stripped_line = strip_syntax(line).strip()
if (
type_of_import == "from"
and stripped_line
Expand All @@ -337,7 +337,7 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte
import_string += line_separator + line
raw_lines.append(line)

stripped_line = _strip_syntax(line).strip()
stripped_line = strip_syntax(line).strip()
if (
type_of_import == "from"
and stripped_line
Expand Down Expand Up @@ -378,7 +378,7 @@ def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedConte

just_imports = [
item.replace("{|", "{ ").replace("|}", " }")
for item in _strip_syntax(import_string).split()
for item in strip_syntax(import_string).split()
]

attach_comments_to: Optional[List[Any]] = None
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_fuzz__infer_line_separator(contents):

@given(import_string=st.text())
def test_fuzz__strip_syntax(import_string):
parse._strip_syntax(import_string=import_string)
parse.strip_syntax(import_string=import_string)


@given(line=st.text(), config=st.builds(Config))
Expand Down

0 comments on commit a8fc20c

Please sign in to comment.