Skip to content

Commit a2159c8

Browse files
committed
tox: fix lint with python 3.12
Fix the following error when running pylint with python 3.12: Exception on node ImportFrom in file 'cffi/build.py' Traceback (most recent call last): File ".../python3.12/site-packages/pylint/checkers/imports.py", line 846, in _get_imported_module return importnode.do_import_module(modname) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../python3.12/site-packages/astroid/nodes/_base_nodes.py", line 146, in do_import_module return mymodule.import_module( ^^^^^^^^^^^^^^^^^^^^^^^ File ".../python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 530, in import_module return AstroidManager().ast_from_module_name( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../python3.12/site-packages/astroid/manager.py", line 246, in ast_from_module_name return self.ast_from_file(found_spec.location, modname, fallback=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../python3.12/site-packages/astroid/manager.py", line 138, in ast_from_file return AstroidBuilder(self).file_build(filepath, modname) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../python3.12/site-packages/astroid/builder.py", line 144, in file_build module, builder = self._data_build(data, modname, path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../python3.12/site-packages/astroid/builder.py", line 204, in _data_build module = builder.visit_module(node, modname, node_file, package) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../python3.12/site-packages/astroid/rebuilder.py", line 254, in visit_module [self.visit(child, newnode) for child in node.body], ^^^^^^^^^^^^^^^^^^^^^^^^^^ File ".../python3.12/site-packages/astroid/rebuilder.py", line 609, in visit visit_method = getattr(self, visit_name) ^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'TreeRebuilder' object has no attribute 'visit_typealias' Update all lint and format dependencies to their latest stable releases. Ignore the new use-implicit-booleaness-not-comparison-to-string and use-implicit-booleaness-not-comparison-to-zero pylint rules. Use the correct Hashable reference from collections.abc instead of the deprecated typing alias. Signed-off-by: Robin Jarry <robin@jarry.cc>
1 parent d8549c8 commit a2159c8

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ jobs:
3939
toxenv: py310
4040
- python: "3.11"
4141
toxenv: py311
42+
- python: "3.12"
43+
toxenv: py312
4244
- python: pypy3.9
4345
toxenv: pypy3
4446
steps:

libyang/keyed_list.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Copyright (c) 2020 6WIND S.A.
22
# SPDX-License-Identifier: MIT
33

4+
from collections.abc import Hashable
45
import copy
5-
from typing import Any, Hashable, Iterable, Optional, Tuple, Union
6+
from typing import Any, Iterable, Optional, Tuple, Union
67

78

89
# -------------------------------------------------------------------------------------

pylintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ disable=
7777
too-many-return-statements,
7878
too-many-statements,
7979
unused-argument,
80+
use-implicit-booleaness-not-comparison-to-string,
81+
use-implicit-booleaness-not-comparison-to-zero,
8082
wrong-import-order,
8183

8284
[REPORTS]

tox.ini

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = format,lint,py{36,37,38,39,310,311,py3,3},lydevel,coverage
2+
envlist = format,lint,py{36,37,38,39,310,311,312,py3,3},lydevel,coverage
33
skip_missing_interpreters = true
44
isolated_build = true
55
distdir = {toxinidir}/dist
@@ -36,8 +36,8 @@ basepython = python3
3636
description = Format python code using isort and black.
3737
changedir = .
3838
deps =
39-
black~=23.1.0
40-
isort~=5.12.0
39+
black~=23.12.1
40+
isort~=5.13.2
4141
skip_install = true
4242
install_command = python3 -m pip install {opts} {packages}
4343
allowlist_externals =
@@ -52,10 +52,14 @@ basepython = python3
5252
description = Run coding style checks.
5353
changedir = .
5454
deps =
55-
black~=23.1.0
56-
flake8~=6.0.0
57-
isort~=5.12.0
58-
pylint~=2.16.2
55+
astroid~=3.0.2
56+
black~=23.12.1
57+
flake8~=7.0.0
58+
isort~=5.13.2
59+
pycodestyle~=2.11.1
60+
pyflakes~=3.2.0
61+
pylint~=3.0.3
62+
setuptools~=69.0.3
5963
allowlist_externals =
6064
/bin/sh
6165
/usr/bin/sh

0 commit comments

Comments
 (0)