Skip to content

Commit

Permalink
test: multi-line f-string removal overextension; fix: same; fix: remo…
Browse files Browse the repository at this point in the history
…val of colon
  • Loading branch information
bionicles committed Jul 4, 2024
1 parent 9a1fa89 commit f1be51f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
12 changes: 12 additions & 0 deletions tests/more_languages/group7/dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,15 @@ def execute(self, *args, **kwargs): ...
output_model: DataClass

def execute(self, *args, **kwargs): ...

@property
def edge_case(self) -> str:
if not self.name and not self.description:
return ""
return f"""Location: {self.config.name}
{self.config.description}
"""

def should_still_see_me(self, x: bool = True) -> "Tool":
pass
3 changes: 3 additions & 0 deletions tests/test_more_language_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,9 @@ def test_more_languages_tensorflow_flags():
"""@dataclass(frozen=True, slots=True, kw_only=True)
class Tool(Protocol)""",
" def execute(self, *args, **kwargs)",
""" @property
def edge_case(self) -> str""",
' def should_still_see_me(self, x: bool = True) -> "Tool"',
]

WGSL_EXPECTATION = [
Expand Down
8 changes: 2 additions & 6 deletions tree_plus_src/parse_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,15 +1042,11 @@ def remove_py_comments(input_string: str) -> str:
# from pygments.lexers.python import PythonLexer


docstring_pattern = re.compile(r"^\s*\"\"\"[\s\S]+?\"\"\"", re.MULTILINE)
docstring_pattern = re.compile(r"(?::)\s^\s+\"\"\"[\s\S]+?\"\"\"", re.MULTILINE)


def remove_docstrings(source):
"""
Remove docstrings from a source code string.
"""
# Matches triple-quoted strings (single or double quotes)
return docstring_pattern.sub("", source)
return docstring_pattern.sub(":", source)


def parse_py(contents: str) -> List[str]:
Expand Down

0 comments on commit f1be51f

Please sign in to comment.