Skip to content

Commit 301b559

Browse files
Require Python 3.7.2 (#1542)
1 parent 1ae8c3d commit 301b559

16 files changed

+96
-179
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
strategy:
8282
fail-fast: true
8383
matrix:
84-
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
84+
python-version: [3.7, 3.8, 3.9, "3.10"]
8585
outputs:
8686
python-key: ${{ steps.generate-python-key.outputs.key }}
8787
steps:
@@ -233,7 +233,7 @@ jobs:
233233
strategy:
234234
fail-fast: true
235235
matrix:
236-
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
236+
python-version: [3.7, 3.8, 3.9, "3.10"]
237237
steps:
238238
- name: Set temp directory
239239
run: echo "TEMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV
@@ -282,7 +282,7 @@ jobs:
282282
strategy:
283283
fail-fast: false
284284
matrix:
285-
python-version: ["pypy-3.6", "pypy-3.7", "pypy-3.8"]
285+
python-version: ["pypy-3.7", "pypy-3.8"]
286286
steps:
287287
- name: Check out code from GitHub
288288
uses: actions/checkout@v3.0.2

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ repos:
3232
hooks:
3333
- id: pyupgrade
3434
exclude: tests/testdata
35-
args: [--py36-plus]
35+
args: [--py37-plus]
3636
- repo: https://github.com/PyCQA/isort
3737
rev: 5.10.1
3838
hooks:

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ What's New in astroid 2.12.0?
66
=============================
77
Release date: TBA
88

9+
* ``astroid`` now requires Python 3.7.2 to run.
10+
911
* Fix ``re`` brain on Python ``3.11``. The flags now come from ``re._compile``.
1012

1113
* Build ``nodes.Module`` for frozen modules which have location information in their

astroid/brain/brain_crypt.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,22 @@
44

55
from astroid.brain.helpers import register_module_extender
66
from astroid.builder import parse
7-
from astroid.const import PY37_PLUS
87
from astroid.manager import AstroidManager
98

10-
if PY37_PLUS:
11-
# Since Python 3.7 Hashing Methods are added
12-
# dynamically to globals()
139

14-
def _re_transform():
15-
return parse(
16-
"""
17-
from collections import namedtuple
18-
_Method = namedtuple('_Method', 'name ident salt_chars total_size')
19-
20-
METHOD_SHA512 = _Method('SHA512', '6', 16, 106)
21-
METHOD_SHA256 = _Method('SHA256', '5', 16, 63)
22-
METHOD_BLOWFISH = _Method('BLOWFISH', 2, 'b', 22)
23-
METHOD_MD5 = _Method('MD5', '1', 8, 34)
24-
METHOD_CRYPT = _Method('CRYPT', None, 2, 13)
10+
def _re_transform():
11+
return parse(
2512
"""
26-
)
13+
from collections import namedtuple
14+
_Method = namedtuple('_Method', 'name ident salt_chars total_size')
15+
16+
METHOD_SHA512 = _Method('SHA512', '6', 16, 106)
17+
METHOD_SHA256 = _Method('SHA256', '5', 16, 63)
18+
METHOD_BLOWFISH = _Method('BLOWFISH', 2, 'b', 22)
19+
METHOD_MD5 = _Method('MD5', '1', 8, 34)
20+
METHOD_CRYPT = _Method('CRYPT', None, 2, 13)
21+
"""
22+
)
23+
2724

28-
register_module_extender(AstroidManager(), "crypt", _re_transform)
25+
register_module_extender(AstroidManager(), "crypt", _re_transform)

astroid/brain/brain_dataclasses.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from astroid import context, inference_tip
1919
from astroid.builder import parse
20-
from astroid.const import PY37_PLUS, PY39_PLUS
20+
from astroid.const import PY39_PLUS
2121
from astroid.exceptions import (
2222
AstroidSyntaxError,
2323
InferenceError,
@@ -449,19 +449,18 @@ def _infer_instance_from_annotation(
449449
yield klass.instantiate_class()
450450

451451

452-
if PY37_PLUS:
453-
AstroidManager().register_transform(
454-
ClassDef, dataclass_transform, is_decorated_with_dataclass
455-
)
452+
AstroidManager().register_transform(
453+
ClassDef, dataclass_transform, is_decorated_with_dataclass
454+
)
456455

457-
AstroidManager().register_transform(
458-
Call,
459-
inference_tip(infer_dataclass_field_call, raise_on_overwrite=True),
460-
_looks_like_dataclass_field_call,
461-
)
456+
AstroidManager().register_transform(
457+
Call,
458+
inference_tip(infer_dataclass_field_call, raise_on_overwrite=True),
459+
_looks_like_dataclass_field_call,
460+
)
462461

463-
AstroidManager().register_transform(
464-
Unknown,
465-
inference_tip(infer_dataclass_attribute, raise_on_overwrite=True),
466-
_looks_like_dataclass_attribute,
467-
)
462+
AstroidManager().register_transform(
463+
Unknown,
464+
inference_tip(infer_dataclass_attribute, raise_on_overwrite=True),
465+
_looks_like_dataclass_attribute,
466+
)

astroid/brain/brain_re.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
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, PY311_PLUS
10+
from astroid.const import PY39_PLUS, PY311_PLUS
1111
from astroid.manager import AstroidManager
1212

1313

@@ -90,7 +90,6 @@ def infer_pattern_match(
9090
return iter([class_def])
9191

9292

93-
if PY37_PLUS:
94-
AstroidManager().register_transform(
95-
nodes.Call, inference_tip(infer_pattern_match), _looks_like_pattern_or_match
96-
)
93+
AstroidManager().register_transform(
94+
nodes.Call, inference_tip(infer_pattern_match), _looks_like_pattern_or_match
95+
)

astroid/brain/brain_subprocess.py

Lines changed: 27 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from astroid.brain.helpers import register_module_extender
88
from astroid.builder import parse
9-
from astroid.const import PY37_PLUS, PY39_PLUS
9+
from astroid.const import PY39_PLUS
1010
from astroid.manager import AstroidManager
1111

1212

@@ -17,9 +17,7 @@ def _subprocess_transform():
1717
self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None,
1818
preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None,
1919
universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True,
20-
start_new_session=False, pass_fds=(), *, encoding=None, errors=None"""
21-
if PY37_PLUS:
22-
args += ", text=None"
20+
start_new_session=False, pass_fds=(), *, encoding=None, errors=None, text=None"""
2321
init = f"""
2422
def __init__({args}):
2523
pass"""
@@ -30,57 +28,31 @@ def __exit__(self, *args): pass
3028
"""
3129
py3_args = "args = []"
3230

33-
if PY37_PLUS:
34-
check_output_signature = """
35-
check_output(
36-
args, *,
37-
stdin=None,
38-
stderr=None,
39-
shell=False,
40-
cwd=None,
41-
encoding=None,
42-
errors=None,
43-
universal_newlines=False,
44-
timeout=None,
45-
env=None,
46-
text=None,
47-
restore_signals=True,
48-
preexec_fn=None,
49-
pass_fds=(),
50-
input=None,
51-
bufsize=0,
52-
executable=None,
53-
close_fds=False,
54-
startupinfo=None,
55-
creationflags=0,
56-
start_new_session=False
57-
):
58-
""".strip()
59-
else:
60-
check_output_signature = """
61-
check_output(
62-
args, *,
63-
stdin=None,
64-
stderr=None,
65-
shell=False,
66-
cwd=None,
67-
encoding=None,
68-
errors=None,
69-
universal_newlines=False,
70-
timeout=None,
71-
env=None,
72-
restore_signals=True,
73-
preexec_fn=None,
74-
pass_fds=(),
75-
input=None,
76-
bufsize=0,
77-
executable=None,
78-
close_fds=False,
79-
startupinfo=None,
80-
creationflags=0,
81-
start_new_session=False
82-
):
83-
""".strip()
31+
check_output_signature = """
32+
check_output(
33+
args, *,
34+
stdin=None,
35+
stderr=None,
36+
shell=False,
37+
cwd=None,
38+
encoding=None,
39+
errors=None,
40+
universal_newlines=False,
41+
timeout=None,
42+
env=None,
43+
text=None,
44+
restore_signals=True,
45+
preexec_fn=None,
46+
pass_fds=(),
47+
input=None,
48+
bufsize=0,
49+
executable=None,
50+
close_fds=False,
51+
startupinfo=None,
52+
creationflags=0,
53+
start_new_session=False
54+
):
55+
""".strip()
8456

8557
code = textwrap.dedent(
8658
f"""

astroid/brain/brain_typing.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from astroid import context, extract_node, inference_tip
1010
from astroid.builder import _extract_single_node
11-
from astroid.const import PY37_PLUS, PY38_PLUS, PY39_PLUS
11+
from astroid.const import PY38_PLUS, PY39_PLUS
1212
from astroid.exceptions import (
1313
AttributeInferenceError,
1414
InferenceError,
@@ -148,22 +148,16 @@ def infer_typing_attr(
148148
except (InferenceError, StopIteration) as exc:
149149
raise UseInferenceDefault from exc
150150

151-
if (
152-
not value.qname().startswith("typing.")
153-
or PY37_PLUS
154-
and value.qname() in TYPING_ALIAS
155-
):
156-
# If typing subscript belongs to an alias
157-
# (PY37+) handle it separately.
151+
if not value.qname().startswith("typing.") or value.qname() in TYPING_ALIAS:
152+
# If typing subscript belongs to an alias handle it separately.
158153
raise UseInferenceDefault
159154

160-
if (
161-
PY37_PLUS
162-
and isinstance(value, ClassDef)
163-
and value.qname()
164-
in {"typing.Generic", "typing.Annotated", "typing_extensions.Annotated"}
165-
):
166-
# With PY37+ typing.Generic and typing.Annotated (PY39) are subscriptable
155+
if isinstance(value, ClassDef) and value.qname() in {
156+
"typing.Generic",
157+
"typing.Annotated",
158+
"typing_extensions.Annotated",
159+
}:
160+
# typing.Generic and typing.Annotated (PY39) are subscriptable
167161
# through __class_getitem__. Since astroid can't easily
168162
# infer the native methods, replace them for an easy inference tip
169163
func_to_add = _extract_single_node(CLASS_GETITEM_TEMPLATE)
@@ -424,10 +418,9 @@ def infer_typing_cast(
424418
ClassDef, inference_tip(infer_old_typedDict), _looks_like_typedDict
425419
)
426420

427-
if PY37_PLUS:
428-
AstroidManager().register_transform(
429-
Call, inference_tip(infer_typing_alias), _looks_like_typing_alias
430-
)
431-
AstroidManager().register_transform(
432-
Call, inference_tip(infer_special_alias), _looks_like_special_alias
433-
)
421+
AstroidManager().register_transform(
422+
Call, inference_tip(infer_typing_alias), _looks_like_typing_alias
423+
)
424+
AstroidManager().register_transform(
425+
Call, inference_tip(infer_special_alias), _looks_like_special_alias
426+
)

astroid/const.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import sys
77
from pathlib import Path
88

9-
PY36 = sys.version_info[:2] == (3, 6)
109
PY38 = sys.version_info[:2] == (3, 8)
11-
PY37_PLUS = sys.version_info >= (3, 7)
1210
PY38_PLUS = sys.version_info >= (3, 8)
1311
PY39_PLUS = sys.version_info >= (3, 9)
1412
PY310_PLUS = sys.version_info >= (3, 10)

astroid/nodes/scoped_nodes/scoped_nodes.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@
1313
import sys
1414
import typing
1515
import warnings
16-
from typing import TYPE_CHECKING, Dict, List, Optional, Set, TypeVar, Union, overload
16+
from typing import (
17+
TYPE_CHECKING,
18+
Dict,
19+
List,
20+
NoReturn,
21+
Optional,
22+
Set,
23+
TypeVar,
24+
Union,
25+
overload,
26+
)
1727

1828
from astroid import bases
1929
from astroid import decorators as decorators_mod
@@ -44,12 +54,6 @@
4454
from astroid.nodes.scoped_nodes.utils import builtin_lookup
4555
from astroid.nodes.utils import Position
4656

47-
if sys.version_info >= (3, 6, 2):
48-
from typing import NoReturn
49-
else:
50-
from typing_extensions import NoReturn
51-
52-
5357
if sys.version_info >= (3, 8):
5458
from functools import cached_property
5559
from typing import Literal

0 commit comments

Comments
 (0)