Skip to content

Commit

Permalink
Merge pull request #3993 from isidentical/issue-3992
Browse files Browse the repository at this point in the history
Make postponed annotations enabled by default for 3.10+
@isidentical and @PCManticore thanks a lot!
  • Loading branch information
hippo91 authored Dec 29, 2020
2 parents f24d765 + 10db2e4 commit 17325f2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,5 @@ contributors:
* Raphael Gaschignard: contributor

* Sorin Sbarnea: contributor

* Batuhan Taskaya: contributor
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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?
===========================
Expand Down
5 changes: 5 additions & 0 deletions pylint/checkers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
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

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


class NoSuchArgumentError(Exception):
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 17325f2

Please sign in to comment.