summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhippo91 <guillaume.peillex@gmail.com>2020-12-29 08:42:31 +0100
committerGitHub <noreply@github.com>2020-12-29 08:42:31 +0100
commit17325f2f7c8cf43f7ae61ba6726b5117cc11066c (patch)
tree1cf89b545a54d0853ab536ba9a76ab0b62782175
parentf24d765d9fb68309d274c0bd1637da5387cb1f80 (diff)
parent10db2e4018a88c418d0e39ff7824414dea4af8c3 (diff)
downloadpylint-git-17325f2f7c8cf43f7ae61ba6726b5117cc11066c.tar.gz
Merge pull request #3993 from isidentical/issue-3992
Make postponed annotations enabled by default for 3.10+ @isidentical and @PCManticore thanks a lot!
-rw-r--r--CONTRIBUTORS.txt2
-rw-r--r--ChangeLog4
-rw-r--r--pylint/checkers/utils.py5
3 files changed, 11 insertions, 0 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index e0e3d6857..19f4842c1 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -433,3 +433,5 @@ contributors:
* Raphael Gaschignard: contributor
* Sorin Sbarnea: contributor
+
+* Batuhan Taskaya: contributor
diff --git a/ChangeLog b/ChangeLog
index e9bbc5230..97ebf5f55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,6 +19,10 @@ Pylint's ChangeLog
* Add missing checks for deprecated functions.
+* Postponed evaluation of annotations are now recognized by default if python version is above 3.10
+
+ Closes #3992
+
What's New in Pylint 2.6.1?
===========================
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index 23836f909..6c707e10f 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -50,6 +50,7 @@ import itertools
import numbers
import re
import string
+import sys
from functools import lru_cache, partial
from typing import Callable, Dict, Iterable, List, Match, Optional, Set, Tuple, Union
@@ -212,6 +213,7 @@ SPECIAL_METHODS_PARAMS = {
for name in methods # type: ignore
}
PYMETHODS = set(SPECIAL_METHODS_PARAMS)
+PY310_PLUS = sys.version_info[:2] >= (3, 10)
class NoSuchArgumentError(Exception):
@@ -1264,6 +1266,9 @@ def get_node_last_lineno(node: astroid.node_classes.NodeNG) -> int:
def is_postponed_evaluation_enabled(node: astroid.node_classes.NodeNG) -> bool:
"""Check if the postponed evaluation of annotations is enabled"""
+ if PY310_PLUS:
+ return True
+
module = node.root()
return "annotations" in module.future_imports