Skip to content

Commit 286b9e6

Browse files
committed
refactor: drop packaging dependency for Cython version check
- parse `Cython.__version__` into a tuple of ints, skipping non-numeric parts so pre-releases like `3.1.0b1` don't raise - remove `packaging` from project dependencies
1 parent f29c9e6 commit 286b9e6

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎cython_lint/cython_lint.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,19 @@
7777
from Cython.Compiler.Nodes import StatListNode
7878
from Cython.Compiler.Nodes import StatNode
7979
from Cython.Compiler.TreeFragment import parse_from_strings
80-
from packaging.version import Version
8180
from tokenize_rt import src_to_tokens
8281
from tokenize_rt import tokens_to_src
8382

8483
from cython_lint import __version__
8584

86-
CYTHON_VERSION = Version(Cython.__version__) # type: ignore[attr-defined]
87-
CYTHON_3 = Version("3")
88-
CYTHON_3_3 = Version("3.3")
85+
# non-numeric parts (e.g. the 'b1' of '3.1.0b1') are dropped
86+
CYTHON_VERSION = tuple(
87+
int(part)
88+
for part in Cython.__version__.split(".") # type: ignore[attr-defined]
89+
if part.isdigit()
90+
)
91+
CYTHON_3 = (3,)
92+
CYTHON_3_3 = (3, 3)
8993
if TYPE_CHECKING:
9094
from collections.abc import Hashable
9195
from collections.abc import Iterator

‎pyproject.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ classifiers = [
1818
]
1919
dependencies = [
2020
"cython>=0.29.32",
21-
"packaging",
2221
"pycodestyle",
2322
"tokenize-rt>=3.2.0",
2423
"tomli;python_version<'3.11'",

0 commit comments

Comments
 (0)