Skip to content

Commit bdbf396

Browse files
authored
Update mypy; add 3.14 to the CI; drop python 3.8 support (#167)
1 parent f859c05 commit bdbf396

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

.github/workflows/build-and-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
- 3.12
2020
- 3.13
2121
# As per https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md#pypy list of versions
22-
- pypy-3.8
2322
- pypy-3.9
2423
- pypy-3.10
2524
astroid-version:
@@ -45,6 +44,7 @@ jobs:
4544
astroid-version: '<4'
4645
- python-version: '3.12'
4746
astroid-version: '<4'
47+
- python-version: '3.14'
4848

4949
env:
5050
COVERALLS_PARALLEL: true
@@ -60,13 +60,13 @@ jobs:
6060

6161
- name: Install dependencies
6262
run: |
63-
pip install --upgrade coveralls pytest setuptools setuptools_scm pep517
63+
pip install --upgrade coveralls "pytest<9.0" setuptools setuptools_scm pep517
6464
pip install .[test] 'astroid${{ matrix.astroid-version }}'
6565
6666
- name: Mypy testing
6767
run: |
6868
# Not an exact mypy version, as we need 0.942 for pypy-3.8 support, but it's not available on 3.5
69-
pip install "mypy>=0.910,<=0.942"
69+
pip install "mypy>=1.10"
7070
python -m mypy asttokens tests/*.py
7171
7272
- name: Fast tests with coverage

asttokens/mark_tokens.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,9 @@ def handle_num(self,
400400

401401
def visit_num(self, node, first_token, last_token):
402402
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]
403-
return self.handle_num(node, cast(ast.Num, node).n, first_token, last_token)
403+
n = node.n # type: ignore[union-attr] # ast.Num has been removed in python 3.14
404+
assert isinstance(n, (complex, int, numbers.Number))
405+
return self.handle_num(node, n, first_token, last_token)
404406

405407
def visit_const(self, node, first_token, last_token):
406408
# type: (AstNode, util.Token, util.Token) -> Tuple[util.Token, util.Token]

asttokens/util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class EnhancedAST(AST):
4646
first_token = None # type: Token
4747
last_token = None # type: Token
4848
lineno = 0 # type: int
49+
end_lineno = 0 # type : int
50+
end_col_offset = 0 # type : int
4951

5052
AstNode = Union[EnhancedAST, NodeNG]
5153

@@ -404,7 +406,7 @@ def combine_tokens(group):
404406

405407

406408
def last_stmt(node):
407-
# type: (ast.AST) -> ast.AST
409+
# type: (AstNode) -> AstNode
408410
"""
409411
If the given AST node contains multiple statements, return the last one.
410412
Otherwise, just return the node.

setup.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ classifiers =
2121
Topic :: Software Development :: Pre-processors
2222
Environment :: Console
2323
Operating System :: OS Independent
24-
Programming Language :: Python :: 3.8
2524
Programming Language :: Python :: 3.9
2625
Programming Language :: Python :: 3.10
2726
Programming Language :: Python :: 3.11
@@ -41,7 +40,7 @@ astroid =
4140
astroid >=2, <5
4241
test =
4342
astroid >=2, <5
44-
pytest
43+
pytest < 9.0
4544
pytest-cov
4645
pytest-xdist
4746

tests/test_mark_tokens.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,9 @@ def test_sys_modules(self):
691691
if time() - start > 13 * 60:
692692
break
693693

694+
if 'annotationlib' == module.__name__:
695+
break
696+
694697
try:
695698
filename = inspect.getsourcefile(module)
696699
except Exception: # some modules raise weird errors

0 commit comments

Comments
 (0)