Skip to content

Commit

Permalink
Fix two linter issues, no longer ignore rule
Browse files Browse the repository at this point in the history
  • Loading branch information
coldfix committed Dec 28, 2024
1 parent c37643c commit 65e323c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ paths.source = [

[tool.ruff]
line-length = 84
lint.ignore = [
"E701",
"E731",
"E741",
]
lint.per-file-ignores = {"src/cpymad/util.py" = ["E701"]}
exclude = [
".git",
"__pycache__",
Expand Down
13 changes: 8 additions & 5 deletions src/cpymad/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ def _fix_name(name: str) -> str:


# precompile regexes for performance:
re_compile = lambda s: re.compile(s, re.IGNORECASE)
def re_compile(s):
return re.compile(s, re.IGNORECASE)


_re_is_identifier = re_compile(r'^[a-z_][a-z0-9_]*$')
_re_symbol = re_compile(r'([a-z_][a-z0-9._]*(->[a-z_][a-z0-9._]*(\[[0-9]+\])?)?)')
_re_element_internal = re_compile(r'^([a-z_][a-z0-9_.$]*)(:\d+)?$')
Expand Down Expand Up @@ -448,10 +451,10 @@ def tokenize(tokens, expr: str):
stop = len(expr)
while i < stop:
for toktype, tokmatch in tokens:
l = tokmatch(expr, i)
if l > 0:
yield Token(toktype, i, l, expr)
i += l
length = tokmatch(expr, i)
if length > 0:
yield Token(toktype, i, length, expr)
i += length
break
else:
raise ValueError("Unknown token {!r} at {!r}"
Expand Down

0 comments on commit 65e323c

Please sign in to comment.