Skip to content

Commit e303cc3

Browse files
committed
Update astroid 4.0.1
1 parent 91d57ad commit e303cc3

File tree

9 files changed

+23
-11
lines changed

9 files changed

+23
-11
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix :ref:`no-name-in-module` for members of ``concurrent.futures`` with Python 3.14.
2+
3+
Closes #10632
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix false-negative where :ref:`unused-import` was not reported for names referenced in a preceding ``global`` statement.
2+
3+
Refs #10633

pylint/checkers/variables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ def visit_global(self, node: nodes.Global) -> None:
16081608

16091609
module = frame.root()
16101610
default_message = True
1611-
locals_ = node.scope().locals
1611+
module_locals = node.root().locals
16121612
for name in node.names:
16131613
try:
16141614
assign_nodes = module.getattr(name)
@@ -1618,7 +1618,7 @@ def visit_global(self, node: nodes.Global) -> None:
16181618

16191619
not_defined_locally_by_import = not any(
16201620
isinstance(local, (nodes.Import, nodes.ImportFrom))
1621-
for local in locals_.get(name, ())
1621+
for local in module_locals.get(name, ())
16221622
)
16231623
if (
16241624
not utils.is_reassigned_after_current(node, name)

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dependencies = [
4040
# Also upgrade requirements_test_min.txt.
4141
# Pinned to dev of second minor update to allow editable installs and fix primer issues,
4242
# see https://github.com/pylint-dev/astroid/issues/1341
43-
"astroid>=4,<=4.1.dev0",
43+
"astroid>=4.0.1,<=4.1.dev0",
4444
"colorama>=0.4.5; sys_platform=='win32'",
4545
"dill>=0.2; python_version<'3.11'",
4646
"dill>=0.3.6; python_version>='3.11'",
@@ -94,7 +94,7 @@ docs = [
9494
# Configuration for the build system
9595
test-min = [
9696
# Base test dependencies
97-
"astroid==4", # Pinned to a specific version for tests
97+
"astroid==4.0.1", # Pinned to a specific version for tests
9898
"py~=1.11.0",
9999
"pytest~=8.4",
100100
"pytest-benchmark~=5.1",

requirements_test_min.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.[testutils,spelling]
22
# astroid dependency is also defined in pyproject.toml
3-
astroid==4.0.0 # Pinned to a specific version for tests
3+
astroid==4.0.1 # Pinned to a specific version for tests
44
typing-extensions~=4.15
55
py~=1.11.0
66
pytest~=8.4

tests/functional/g/globals.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ def define_constant():
3737
def global_with_import():
3838
"""should only warn for global-statement when using `Import` node"""
3939
global sys # [global-statement]
40-
import sys
40+
import sys # [unused-import]
4141

4242

4343
def global_with_import_from():
4444
"""should only warn for global-statement when using `ImportFrom` node"""
4545
global namedtuple # [global-statement]
46-
from collections import namedtuple
46+
from collections import namedtuple # [unused-import]
4747

4848

4949
def global_no_assign():

tests/functional/g/globals.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ global-variable-not-assigned:27:4:27:14:other:Using global for 'HOP' but no assi
55
undefined-variable:28:10:28:13:other:Undefined variable 'HOP':UNDEFINED
66
global-variable-undefined:33:4:33:18:define_constant:Global variable 'SOMEVAR' undefined at the module level:HIGH
77
global-statement:39:4:39:14:global_with_import:Using the global statement:HIGH
8+
unused-import:40:4:40:14:global_with_import:Unused import sys:UNDEFINED
89
global-statement:45:4:45:21:global_with_import_from:Using the global statement:HIGH
10+
unused-import:46:4:46:38:global_with_import_from:Unused namedtuple imported from collections:UNDEFINED
911
global-variable-not-assigned:51:4:51:19:global_no_assign:Using global for 'CONSTANT' but no assignment is done:HIGH
1012
global-statement:57:4:57:19:global_del:Using the global statement:HIGH
1113
global-statement:64:4:64:19:global_operator_assign:Using the global statement:HIGH

tests/functional/u/unused/unused_variable.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ def test_global():
9595
"""
9696
# pylint: disable=redefined-outer-name
9797
global PATH, OS, collections, deque # [global-statement]
98-
from os import path as PATH
99-
import os as OS
100-
import collections
101-
from collections import deque
98+
from os import path as PATH # [unused-import]
99+
import os as OS # [unused-import]
100+
import collections # [unused-import]
101+
from collections import deque # [unused-import]
102102
# make sure that these triggers unused-variable
103103
from sys import platform # [unused-import]
104104
from sys import version as VERSION # [unused-import]

tests/functional/u/unused/unused_variable.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ unused-import:59:4:59:40:unused_import_in_function:Unused hexdigits imported fro
1414
unused-variable:64:4:64:10:hello:Unused variable 'my_var':UNDEFINED
1515
unused-variable:75:4:75:8:function:Unused variable 'aaaa':UNDEFINED
1616
global-statement:97:4:97:39:test_global:Using the global statement:HIGH
17+
unused-import:98:4:98:31:test_global:Unused path imported from os as PATH:UNDEFINED
18+
unused-import:99:4:99:19:test_global:Unused os imported as OS:UNDEFINED
19+
unused-import:100:4:100:22:test_global:Unused import collections:UNDEFINED
20+
unused-import:101:4:101:33:test_global:Unused deque imported from collections:UNDEFINED
1721
unused-import:103:4:103:28:test_global:Unused platform imported from sys:UNDEFINED
1822
unused-import:104:4:104:38:test_global:Unused version imported from sys as VERSION:UNDEFINED
1923
unused-import:105:4:105:15:test_global:Unused import this:UNDEFINED

0 commit comments

Comments
 (0)