File tree Expand file tree Collapse file tree 6 files changed +51
-18
lines changed Expand file tree Collapse file tree 6 files changed +51
-18
lines changed Original file line number Diff line number Diff line change 1+ Fixed a false positive ``unreachable-code`` when using ``typing.Any`` as return type in python
2+ 3.8, the ``typing.NoReturn`` are not taken into account anymore for python 3.8 however.
3+
4+ Closes #9751
Original file line number Diff line number Diff line change @@ -2184,7 +2184,9 @@ def is_terminating_func(node: nodes.Call) -> bool:
21842184 * TYPING_NEVER ,
21852185 * TYPING_NORETURN ,
21862186 # In Python 3.7 - 3.8, NoReturn is alias of '_SpecialForm'
2187- "typing._SpecialForm" ,
2187+ # "typing._SpecialForm",
2188+ # But 'typing.Any' also inherits _SpecialForm
2189+ # See #9751
21882190 )
21892191 ):
21902192 return True
Original file line number Diff line number Diff line change 1+ """
2+ pylint 3.2.4 regression
3+ https://github.com/pylint-dev/pylint/issues/9751
4+ """
5+
6+ # pylint: disable=missing-function-docstring
7+
8+ from typing import Any
9+
10+ def repro () -> Any :
11+ return 5
12+
13+ def main ():
14+ x = repro () + 5
15+ print (x )
Original file line number Diff line number Diff line change 22# pylint: disable=consider-using-f-string, missing-function-docstring
33import datetime
44import sys
5- from typing import NoReturn
5+ # from typing import NoReturn # uncomment when we reunite with used_before_assignment_py38.py
66
77MSG = "hello %s" % MSG # [used-before-assignment]
88
@@ -206,19 +206,3 @@ def inner_if_continues_outer_if_has_no_other_statements():
206206 else :
207207 order = None
208208 print (order )
209-
210-
211- class PlatformChecks :
212- """https://github.com/pylint-dev/pylint/issues/9674"""
213- def skip (self , msg ) -> NoReturn :
214- raise Exception (msg ) # pylint: disable=broad-exception-raised
215-
216- def print_platform_specific_command (self ):
217- if sys .platform == "linux" :
218- cmd = "ls"
219- elif sys .platform == "win32" :
220- cmd = "dir"
221- else :
222- self .skip ("only runs on Linux/Windows" )
223-
224- print (cmd )
Original file line number Diff line number Diff line change 1+ """
2+ Temporary file until we drop python 3.8
3+ See https://github.com/pylint-dev/pylint/issues/9751
4+ Please reunite with used_before_assignment.py at this point
5+ """
6+
7+ # pylint: disable=missing-docstring
8+
9+ import sys
10+ from typing import NoReturn
11+
12+
13+ class PlatformChecks :
14+ """https://github.com/pylint-dev/pylint/issues/9674"""
15+ def skip (self , msg ) -> NoReturn :
16+ raise Exception (msg ) # pylint: disable=broad-exception-raised
17+
18+ def print_platform_specific_command (self ):
19+ if sys .platform == "linux" :
20+ cmd = "ls"
21+ elif sys .platform == "win32" :
22+ cmd = "dir"
23+ else :
24+ self .skip ("only runs on Linux/Windows" )
25+
26+ print (cmd )
Original file line number Diff line number Diff line change 1+ [testoptions]
2+ min_pyver=3.9
You can’t perform that action at this time.
0 commit comments