Skip to content

Commit 17325f2

Browse files
authored
Merge pull request #3993 from isidentical/issue-3992
Make postponed annotations enabled by default for 3.10+ @isidentical and @PCManticore thanks a lot!
2 parents f24d765 + 10db2e4 commit 17325f2

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

CONTRIBUTORS.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,5 @@ contributors:
433433
* Raphael Gaschignard: contributor
434434

435435
* Sorin Sbarnea: contributor
436+
437+
* Batuhan Taskaya: contributor

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Pylint's ChangeLog
1919

2020
* Add missing checks for deprecated functions.
2121

22+
* Postponed evaluation of annotations are now recognized by default if python version is above 3.10
23+
24+
Closes #3992
25+
2226

2327
What's New in Pylint 2.6.1?
2428
===========================

pylint/checkers/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import numbers
5151
import re
5252
import string
53+
import sys
5354
from functools import lru_cache, partial
5455
from typing import Callable, Dict, Iterable, List, Match, Optional, Set, Tuple, Union
5556

@@ -212,6 +213,7 @@
212213
for name in methods # type: ignore
213214
}
214215
PYMETHODS = set(SPECIAL_METHODS_PARAMS)
216+
PY310_PLUS = sys.version_info[:2] >= (3, 10)
215217

216218

217219
class NoSuchArgumentError(Exception):
@@ -1264,6 +1266,9 @@ def get_node_last_lineno(node: astroid.node_classes.NodeNG) -> int:
12641266

12651267
def is_postponed_evaluation_enabled(node: astroid.node_classes.NodeNG) -> bool:
12661268
"""Check if the postponed evaluation of annotations is enabled"""
1269+
if PY310_PLUS:
1270+
return True
1271+
12671272
module = node.root()
12681273
return "annotations" in module.future_imports
12691274

0 commit comments

Comments
 (0)