summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--astroid/brain/brain_fstrings.py14
-rw-r--r--astroid/brain/brain_hashlib.py30
-rw-r--r--astroid/brain/brain_re.py52
-rw-r--r--astroid/brain/brain_subprocess.py42
-rw-r--r--astroid/constants.py1
-rw-r--r--astroid/scoped_nodes.py4
-rw-r--r--tests/unittest_brain.py1
7 files changed, 57 insertions, 87 deletions
diff --git a/astroid/brain/brain_fstrings.py b/astroid/brain/brain_fstrings.py
index bd98a8ba..26a8cbc3 100644
--- a/astroid/brain/brain_fstrings.py
+++ b/astroid/brain/brain_fstrings.py
@@ -8,7 +8,6 @@
import collections.abc
import astroid
-from astroid.constants import PY36
def _clone_node_with_lineno(node, parent, lineno):
@@ -44,11 +43,8 @@ def _transform_formatted_value(node): # pylint: disable=inconsistent-return-sta
return new_node
-if PY36:
- # TODO: this fix tries to *patch* http://bugs.python.org/issue29051
- # The problem is that FormattedValue.value, which is a Name node,
- # has wrong line numbers, usually 1. This creates problems for pylint,
- # which expects correct line numbers for things such as message control.
- astroid.MANAGER.register_transform(
- astroid.FormattedValue, _transform_formatted_value
- )
+# TODO: this fix tries to *patch* http://bugs.python.org/issue29051
+# The problem is that FormattedValue.value, which is a Name node,
+# has wrong line numbers, usually 1. This creates problems for pylint,
+# which expects correct line numbers for things such as message control.
+astroid.MANAGER.register_transform(astroid.FormattedValue, _transform_formatted_value)
diff --git a/astroid/brain/brain_hashlib.py b/astroid/brain/brain_hashlib.py
index f7524847..af3f50b7 100644
--- a/astroid/brain/brain_hashlib.py
+++ b/astroid/brain/brain_hashlib.py
@@ -10,7 +10,6 @@
# For details: https://github.com/PyCQA/astroid/blob/master/LICENSE
import astroid
-from astroid.constants import PY36
def _hashlib_transform():
@@ -38,21 +37,20 @@ def _hashlib_transform():
algorithms_with_signature = dict.fromkeys(
["md5", "sha1", "sha224", "sha256", "sha384", "sha512"], signature
)
- if PY36:
- blake2b_signature = "data=b'', *, digest_size=64, key=b'', salt=b'', \
- person=b'', fanout=1, depth=1, leaf_size=0, node_offset=0, \
- node_depth=0, inner_size=0, last_node=False"
- blake2s_signature = "data=b'', *, digest_size=32, key=b'', salt=b'', \
- person=b'', fanout=1, depth=1, leaf_size=0, node_offset=0, \
- node_depth=0, inner_size=0, last_node=False"
- new_algorithms = dict.fromkeys(
- ["sha3_224", "sha3_256", "sha3_384", "sha3_512", "shake_128", "shake_256"],
- signature,
- )
- algorithms_with_signature.update(new_algorithms)
- algorithms_with_signature.update(
- {"blake2b": blake2b_signature, "blake2s": blake2s_signature}
- )
+ blake2b_signature = "data=b'', *, digest_size=64, key=b'', salt=b'', \
+ person=b'', fanout=1, depth=1, leaf_size=0, node_offset=0, \
+ node_depth=0, inner_size=0, last_node=False"
+ blake2s_signature = "data=b'', *, digest_size=32, key=b'', salt=b'', \
+ person=b'', fanout=1, depth=1, leaf_size=0, node_offset=0, \
+ node_depth=0, inner_size=0, last_node=False"
+ new_algorithms = dict.fromkeys(
+ ["sha3_224", "sha3_256", "sha3_384", "sha3_512", "shake_128", "shake_256"],
+ signature,
+ )
+ algorithms_with_signature.update(new_algorithms)
+ algorithms_with_signature.update(
+ {"blake2b": blake2b_signature, "blake2s": blake2s_signature}
+ )
classes = "".join(
template % {"name": hashfunc, "digest": 'b""', "signature": signature}
for hashfunc, signature in algorithms_with_signature.items()
diff --git a/astroid/brain/brain_re.py b/astroid/brain/brain_re.py
index 46acf5ca..e825578e 100644
--- a/astroid/brain/brain_re.py
+++ b/astroid/brain/brain_re.py
@@ -3,37 +3,37 @@
import astroid
from astroid import MANAGER, context, inference_tip, nodes
-from astroid.constants import PY36, PY37, PY39
+from astroid.constants import PY37, PY39
-if PY36:
+
+def _re_transform():
# Since Python 3.6 there is the RegexFlag enum
# where every entry will be exposed via updating globals()
-
- def _re_transform():
- return astroid.parse(
- """
- import sre_compile
- ASCII = sre_compile.SRE_FLAG_ASCII
- IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE
- LOCALE = sre_compile.SRE_FLAG_LOCALE
- UNICODE = sre_compile.SRE_FLAG_UNICODE
- MULTILINE = sre_compile.SRE_FLAG_MULTILINE
- DOTALL = sre_compile.SRE_FLAG_DOTALL
- VERBOSE = sre_compile.SRE_FLAG_VERBOSE
- A = ASCII
- I = IGNORECASE
- L = LOCALE
- U = UNICODE
- M = MULTILINE
- S = DOTALL
- X = VERBOSE
- TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE
- T = TEMPLATE
- DEBUG = sre_compile.SRE_FLAG_DEBUG
+ return astroid.parse(
"""
- )
+ import sre_compile
+ ASCII = sre_compile.SRE_FLAG_ASCII
+ IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE
+ LOCALE = sre_compile.SRE_FLAG_LOCALE
+ UNICODE = sre_compile.SRE_FLAG_UNICODE
+ MULTILINE = sre_compile.SRE_FLAG_MULTILINE
+ DOTALL = sre_compile.SRE_FLAG_DOTALL
+ VERBOSE = sre_compile.SRE_FLAG_VERBOSE
+ A = ASCII
+ I = IGNORECASE
+ L = LOCALE
+ U = UNICODE
+ M = MULTILINE
+ S = DOTALL
+ X = VERBOSE
+ TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE
+ T = TEMPLATE
+ DEBUG = sre_compile.SRE_FLAG_DEBUG
+ """
+ )
+
- astroid.register_module_extender(astroid.MANAGER, "re", _re_transform)
+astroid.register_module_extender(astroid.MANAGER, "re", _re_transform)
CLASS_GETITEM_TEMPLATE = """
diff --git a/astroid/brain/brain_subprocess.py b/astroid/brain/brain_subprocess.py
index d56cb166..d4a9100a 100644
--- a/astroid/brain/brain_subprocess.py
+++ b/astroid/brain/brain_subprocess.py
@@ -14,44 +14,22 @@
import textwrap
import astroid
-from astroid.constants import PY36, PY37, PY39
+from astroid.constants import PY37, PY39
def _subprocess_transform():
communicate = (bytes("string", "ascii"), bytes("string", "ascii"))
communicate_signature = "def communicate(self, input=None, timeout=None)"
+ args = """\
+ self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None,
+ preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None,
+ universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True,
+ start_new_session=False, pass_fds=(), *, encoding=None, errors=None"""
if PY37:
- init = """
- def __init__(self, args, bufsize=0, executable=None,
- stdin=None, stdout=None, stderr=None,
- preexec_fn=None, close_fds=False, shell=False,
- cwd=None, env=None, universal_newlines=False,
- startupinfo=None, creationflags=0, restore_signals=True,
- start_new_session=False, pass_fds=(), *,
- encoding=None, errors=None, text=None):
- pass
- """
- elif PY36:
- init = """
- def __init__(self, args, bufsize=0, executable=None,
- stdin=None, stdout=None, stderr=None,
- preexec_fn=None, close_fds=False, shell=False,
- cwd=None, env=None, universal_newlines=False,
- startupinfo=None, creationflags=0, restore_signals=True,
- start_new_session=False, pass_fds=(), *,
- encoding=None, errors=None):
- pass
- """
- else:
- init = """
- def __init__(self, args, bufsize=0, executable=None,
- stdin=None, stdout=None, stderr=None,
- preexec_fn=None, close_fds=False, shell=False,
- cwd=None, env=None, universal_newlines=False,
- startupinfo=None, creationflags=0, restore_signals=True,
- start_new_session=False, pass_fds=()):
- pass
- """
+ args += ", text=None"
+ init = f"""
+ def __init__({args}):
+ pass"""
wait_signature = "def wait(self, timeout=None)"
ctx_manager = """
def __enter__(self): return self
diff --git a/astroid/constants.py b/astroid/constants.py
index f9110dbd..3b0b3c67 100644
--- a/astroid/constants.py
+++ b/astroid/constants.py
@@ -1,6 +1,5 @@
import sys
-PY36 = sys.version_info >= (3, 6)
PY37 = sys.version_info >= (3, 7)
PY38 = sys.version_info >= (3, 8)
PY39 = sys.version_info >= (3, 9)
diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py
index c3603c63..334af2d9 100644
--- a/astroid/scoped_nodes.py
+++ b/astroid/scoped_nodes.py
@@ -47,7 +47,7 @@ from astroid import bases
from astroid import context as contextmod
from astroid import decorators as decorators_mod
from astroid import manager, mixins, node_classes, util
-from astroid.constants import PY36, PY39
+from astroid.constants import PY39
from astroid.exceptions import (
AstroidBuildingError,
AstroidTypeError,
@@ -1514,7 +1514,7 @@ class FunctionDef(mixins.MultiLineBlockMixin, node_classes.Statement, Lambda):
if isinstance(frame, ClassDef):
if self.name == "__new__":
return "classmethod"
- if PY36 and self.name == "__init_subclass__":
+ if self.name == "__init_subclass__":
return "classmethod"
type_name = "method"
diff --git a/tests/unittest_brain.py b/tests/unittest_brain.py
index 8343e397..7ea29802 100644
--- a/tests/unittest_brain.py
+++ b/tests/unittest_brain.py
@@ -1355,7 +1355,6 @@ class CollectionsBrain(unittest.TestCase):
)
-@test_utils.require_version("3.6")
class TypingBrain(unittest.TestCase):
def test_namedtuple_base(self):
klass = builder.extract_node(