Skip to content

Commit b6fbe3c

Browse files
Merge branch 'main' into pipe-output
2 parents 71f798b + 519ae7a commit b6fbe3c

34 files changed

+480
-360
lines changed

.github/workflows/ci.yaml

Lines changed: 77 additions & 166 deletions
Large diffs are not rendered by default.

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ jobs:
3939

4040
steps:
4141
- name: Checkout repository
42-
uses: actions/[email protected].0
42+
uses: actions/[email protected].2
4343

4444
# Initializes the CodeQL tools for scanning.
4545
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v1
46+
uses: github/codeql-action/init@v2
4747
with:
4848
languages: ${{ matrix.language }}
4949
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -54,7 +54,7 @@ jobs:
5454
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5555
# If this step fails, then you should remove it and run the build manually (see below)
5656
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v1
57+
uses: github/codeql-action/autobuild@v2
5858

5959
# ℹ️ Command-line programs to run using the OS shell.
6060
# 📚 https://git.io/JvXDl
@@ -68,4 +68,4 @@ jobs:
6868
# make release
6969

7070
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v1
71+
uses: github/codeql-action/analyze@v2

.github/workflows/release-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
timeout-minutes: 5
1414
steps:
1515
- name: Check out code from GitHub
16-
uses: actions/[email protected].0
16+
uses: actions/[email protected].2
1717
- name: Set up Python
1818
id: python
19-
uses: actions/[email protected].0
19+
uses: actions/[email protected].2
2020
with:
2121
python-version: ${{ env.DEFAULT_PYTHON }}
2222
- name: Create Python virtual environment with virtualenv==15.1.0

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Check out code from Github
17-
uses: actions/[email protected].0
17+
uses: actions/[email protected].2
1818
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
1919
id: python
20-
uses: actions/[email protected].0
20+
uses: actions/[email protected].2
2121
with:
2222
python-version: ${{ env.DEFAULT_PYTHON }}
2323
- name: Install requirements

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ci:
33

44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.1.0
6+
rev: v4.2.0
77
hooks:
88
- id: trailing-whitespace
99
exclude: .github/|tests/testdata
@@ -28,7 +28,7 @@ repos:
2828
exclude: tests/testdata|setup.py
2929
types: [python]
3030
- repo: https://github.com/asottile/pyupgrade
31-
rev: v2.31.1
31+
rev: v2.32.0
3232
hooks:
3333
- id: pyupgrade
3434
exclude: tests/testdata
@@ -90,7 +90,7 @@ repos:
9090
]
9191
exclude: tests/testdata| # exclude everything, we're not ready
9292
- repo: https://github.com/pre-commit/mirrors-prettier
93-
rev: v2.6.1
93+
rev: v2.6.2
9494
hooks:
9595
- id: prettier
9696
args: [--prose-wrap=always, --print-width=88]

CONTRIBUTORS.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ Contributors
3838
- Julien Jehannet <[email protected]>
3939
- Calen Pennington <[email protected]>
4040
- Phil Schaf <[email protected]>
41+
- Hugo van Kemenade <[email protected]>
4142
- Alex Hall <[email protected]>
4243
- Tushar Sadhwani <[email protected]>
4344
- Tim Martin <[email protected]>
4445
- Raphael Gaschignard <[email protected]>
4546
- Radosław Ganczarek <[email protected]>
47+
- Paligot Gérard <[email protected]>
4648
- Ioana Tagirta <[email protected]>
47-
4849
- Derek Gustafson <[email protected]>
4950
- David Shea <[email protected]>
5051
- Daniel Harding <[email protected]>
@@ -55,7 +56,6 @@ Contributors
5556
- Marien Zwart <[email protected]>
5657
- FELD Boris <[email protected]>
5758
- Enji Cooper <[email protected]>
58-
- AndroWiiid <[email protected]>
5959
- doranid <[email protected]>
6060
- brendanator <[email protected]>
6161
- Tomas Gavenciak <[email protected]>
@@ -105,7 +105,6 @@ Contributors
105105
- Philipp Hörist <[email protected]>
106106
- Peter de Blanc <[email protected]>
107107
- Peter Talley <[email protected]>
108-
- Paligot Gérard <[email protected]>
109108
- Ovidiu Sabou <[email protected]>
110109
- Nicolas Noirbent <[email protected]>
111110
- Neil Girdhar <[email protected]>
@@ -127,7 +126,6 @@ Contributors
127126
- Jakub Wilk <[email protected]>
128127
- Iva Miholic <[email protected]>
129128
- Ionel Maries Cristian <[email protected]>
130-
- Hugo van Kemenade <[email protected]>
131129
- HoverHell <[email protected]>
132130
- HQupgradeHQ <[email protected]>
133131
- Grygorii Iermolenko <[email protected]>

ChangeLog

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,49 @@ Release date: TBA
1111

1212
Closes PyCQA/pylint#3518
1313

14+
* Fix ``re`` brain on Python ``3.11``. The flags now come from ``re._compile``.
1415

15-
What's New in astroid 2.11.3?
16+
* Build ``nodes.Module`` for frozen modules which have location information in their
17+
``ModuleSpec``.
18+
19+
Closes #1512
20+
21+
* Rename ``ModuleSpec`` -> ``module_type`` constructor parameter to match attribute
22+
name and improve typing. Use ``type`` instead.
23+
24+
25+
What's New in astroid 2.11.4?
1626
=============================
1727
Release date: TBA
1828

29+
* Fix ``col_offset`` attribute for nodes involving ``with`` on ``PyPy``.
30+
31+
* Fixed a crash involving two starred expressions: one inside a comprehension,
32+
both inside a call.
33+
34+
Refs PyCQA/pylint#6372
35+
36+
* Made ``FunctionDef.implicit_parameters`` return 1 for methods by making
37+
``FunctionDef.is_bound`` return ``True``, as it does for class methods.
38+
39+
Closes PyCQA/pylint#6464
40+
41+
* Fixed a crash when ``_filter_stmts`` encounters an ``EmptyNode``.
42+
43+
Closes PyCQA/pylint#6438
44+
45+
46+
What's New in astroid 2.11.3?
47+
=============================
48+
Release date: 2022-04-19
49+
50+
* Fixed an error in the Qt brain when building ``instance_attrs``.
51+
52+
Closes PyCQA/pylint#6221
53+
54+
* Fixed a crash in the ``gi`` brain.
55+
56+
Closes PyCQA/pylint#6371
1957

2058

2159
What's New in astroid 2.11.2?

astroid/_ast.py

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
import ast
66
import sys
77
import types
8-
from collections import namedtuple
98
from functools import partial
10-
from typing import Dict, Optional
9+
from typing import Dict, List, NamedTuple, Optional, Type
1110

1211
from astroid.const import PY38_PLUS, Context
1312

@@ -20,23 +19,21 @@
2019
except ImportError:
2120
_ast_py3 = None
2221

23-
FunctionType = namedtuple("FunctionType", ["argtypes", "returns"])
2422

23+
class FunctionType(NamedTuple):
24+
argtypes: List[ast.expr]
25+
returns: ast.expr
2526

26-
class ParserModule(
27-
namedtuple(
28-
"ParserModule",
29-
[
30-
"module",
31-
"unary_op_classes",
32-
"cmp_op_classes",
33-
"bool_op_classes",
34-
"bin_op_classes",
35-
"context_classes",
36-
],
37-
)
38-
):
39-
def parse(self, string: str, type_comments=True):
27+
28+
class ParserModule(NamedTuple):
29+
module: types.ModuleType
30+
unary_op_classes: Dict[Type[ast.unaryop], str]
31+
cmp_op_classes: Dict[Type[ast.cmpop], str]
32+
bool_op_classes: Dict[Type[ast.boolop], str]
33+
bin_op_classes: Dict[Type[ast.operator], str]
34+
context_classes: Dict[Type[ast.expr_context], Context]
35+
36+
def parse(self, string: str, type_comments: bool = True) -> ast.Module:
4037
if self.module is _ast_py3:
4138
if PY38_PLUS:
4239
parse_func = partial(self.module.parse, type_comments=type_comments)
@@ -58,7 +55,7 @@ def parse_function_type_comment(type_comment: str) -> Optional[FunctionType]:
5855
return FunctionType(argtypes=func_type.argtypes, returns=func_type.returns)
5956

6057

61-
def get_parser_module(type_comments=True) -> ParserModule:
58+
def get_parser_module(type_comments: bool = True) -> ParserModule:
6259
parser_module = ast
6360
if type_comments and _ast_py3:
6461
parser_module = _ast_py3
@@ -79,11 +76,15 @@ def get_parser_module(type_comments=True) -> ParserModule:
7976
)
8077

8178

82-
def _unary_operators_from_module(module):
79+
def _unary_operators_from_module(
80+
module: types.ModuleType,
81+
) -> Dict[Type[ast.unaryop], str]:
8382
return {module.UAdd: "+", module.USub: "-", module.Not: "not", module.Invert: "~"}
8483

8584

86-
def _binary_operators_from_module(module):
85+
def _binary_operators_from_module(
86+
module: types.ModuleType,
87+
) -> Dict[Type[ast.operator], str]:
8788
binary_operators = {
8889
module.Add: "+",
8990
module.BitAnd: "&",
@@ -102,11 +103,15 @@ def _binary_operators_from_module(module):
102103
return binary_operators
103104

104105

105-
def _bool_operators_from_module(module):
106+
def _bool_operators_from_module(
107+
module: types.ModuleType,
108+
) -> Dict[Type[ast.boolop], str]:
106109
return {module.And: "and", module.Or: "or"}
107110

108111

109-
def _compare_operators_from_module(module):
112+
def _compare_operators_from_module(
113+
module: types.ModuleType,
114+
) -> Dict[Type[ast.cmpop], str]:
110115
return {
111116
module.Eq: "==",
112117
module.Gt: ">",
@@ -121,7 +126,9 @@ def _compare_operators_from_module(module):
121126
}
122127

123128

124-
def _contexts_from_module(module) -> Dict[ast.expr_context, Context]:
129+
def _contexts_from_module(
130+
module: types.ModuleType,
131+
) -> Dict[Type[ast.expr_context], Context]:
125132
return {
126133
module.Load: Context.Load,
127134
module.Store: Context.Store,

astroid/brain/brain_gi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ def _gi_build_stub(parent):
7474

7575
try:
7676
obj = getattr(parent, name)
77-
except AttributeError:
77+
except Exception: # pylint: disable=broad-except
78+
# gi.module.IntrospectionModule.__getattr__() can raise all kinds of things
79+
# like ValueError, TypeError, NotImplementedError, RepositoryError, etc
7880
continue
7981

8082
if inspect.isclass(obj):

astroid/brain/brain_qt.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def _looks_like_signal(node, signal_name="pyqtSignal"):
2121
return False
2222

2323

24-
def transform_pyqt_signal(node):
24+
def transform_pyqt_signal(node: nodes.FunctionDef) -> None:
2525
module = parse(
2626
"""
2727
class pyqtSignal(object):
@@ -33,13 +33,13 @@ def emit(self, *args):
3333
pass
3434
"""
3535
)
36-
signal_cls = module["pyqtSignal"]
37-
node.instance_attrs["emit"] = signal_cls["emit"]
38-
node.instance_attrs["disconnect"] = signal_cls["disconnect"]
39-
node.instance_attrs["connect"] = signal_cls["connect"]
36+
signal_cls: nodes.ClassDef = module["pyqtSignal"]
37+
node.instance_attrs["emit"] = [signal_cls["emit"]]
38+
node.instance_attrs["disconnect"] = [signal_cls["disconnect"]]
39+
node.instance_attrs["connect"] = [signal_cls["connect"]]
4040

4141

42-
def transform_pyside_signal(node):
42+
def transform_pyside_signal(node: nodes.FunctionDef) -> None:
4343
module = parse(
4444
"""
4545
class NotPySideSignal(object):
@@ -51,10 +51,10 @@ def emit(self, *args):
5151
pass
5252
"""
5353
)
54-
signal_cls = module["NotPySideSignal"]
55-
node.instance_attrs["connect"] = signal_cls["connect"]
56-
node.instance_attrs["disconnect"] = signal_cls["disconnect"]
57-
node.instance_attrs["emit"] = signal_cls["emit"]
54+
signal_cls: nodes.ClassDef = module["NotPySideSignal"]
55+
node.instance_attrs["connect"] = [signal_cls["connect"]]
56+
node.instance_attrs["disconnect"] = [signal_cls["disconnect"]]
57+
node.instance_attrs["emit"] = [signal_cls["emit"]]
5858

5959

6060
def pyqt4_qtcore_transform():

astroid/brain/brain_re.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,39 @@
77
from astroid import context, inference_tip, nodes
88
from astroid.brain.helpers import register_module_extender
99
from astroid.builder import _extract_single_node, parse
10-
from astroid.const import PY37_PLUS, PY39_PLUS
10+
from astroid.const import PY37_PLUS, PY39_PLUS, PY311_PLUS
1111
from astroid.manager import AstroidManager
1212

1313

14-
def _re_transform():
15-
# Since Python 3.6 there is the RegexFlag enum
16-
# where every entry will be exposed via updating globals()
14+
def _re_transform() -> nodes.Module:
15+
# The RegexFlag enum exposes all its entries by updating globals()
16+
# In 3.6-3.10 all flags come from sre_compile
17+
# On 3.11+ all flags come from re._compiler
18+
if PY311_PLUS:
19+
import_compiler = "import re._compiler as _compiler"
20+
else:
21+
import_compiler = "import sre_compile as _compiler"
1722
return parse(
18-
"""
19-
import sre_compile
20-
ASCII = sre_compile.SRE_FLAG_ASCII
21-
IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE
22-
LOCALE = sre_compile.SRE_FLAG_LOCALE
23-
UNICODE = sre_compile.SRE_FLAG_UNICODE
24-
MULTILINE = sre_compile.SRE_FLAG_MULTILINE
25-
DOTALL = sre_compile.SRE_FLAG_DOTALL
26-
VERBOSE = sre_compile.SRE_FLAG_VERBOSE
23+
f"""
24+
{import_compiler}
25+
NOFLAG = 0
26+
ASCII = _compiler.SRE_FLAG_ASCII
27+
IGNORECASE = _compiler.SRE_FLAG_IGNORECASE
28+
LOCALE = _compiler.SRE_FLAG_LOCALE
29+
UNICODE = _compiler.SRE_FLAG_UNICODE
30+
MULTILINE = _compiler.SRE_FLAG_MULTILINE
31+
DOTALL = _compiler.SRE_FLAG_DOTALL
32+
VERBOSE = _compiler.SRE_FLAG_VERBOSE
33+
TEMPLATE = _compiler.SRE_FLAG_TEMPLATE
34+
DEBUG = _compiler.SRE_FLAG_DEBUG
2735
A = ASCII
2836
I = IGNORECASE
2937
L = LOCALE
3038
U = UNICODE
3139
M = MULTILINE
3240
S = DOTALL
3341
X = VERBOSE
34-
TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE
3542
T = TEMPLATE
36-
DEBUG = sre_compile.SRE_FLAG_DEBUG
3743
"""
3844
)
3945

astroid/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
PY38_PLUS = sys.version_info >= (3, 8)
1212
PY39_PLUS = sys.version_info >= (3, 9)
1313
PY310_PLUS = sys.version_info >= (3, 10)
14+
PY311_PLUS = sys.version_info >= (3, 11)
1415
BUILTINS = "builtins" # TODO Remove in 2.8
1516

1617
WIN32 = sys.platform == "win32"

0 commit comments

Comments
 (0)