-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[unreachable-code] Fix the false positive in python 3.8 (#9753)
Refs #9751 Co-authored-by: John Snow <[email protected]>
- Loading branch information
1 parent
d8f84b0
commit d281f2f
Showing
6 changed files
with
51 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Fixed a false positive ``unreachable-code`` when using ``typing.Any`` as return type in python | ||
3.8, the ``typing.NoReturn`` are not taken into account anymore for python 3.8 however. | ||
|
||
Closes #9751 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
pylint 3.2.4 regression | ||
https://github.com/pylint-dev/pylint/issues/9751 | ||
""" | ||
|
||
# pylint: disable=missing-function-docstring | ||
|
||
from typing import Any | ||
|
||
def repro() -> Any: | ||
return 5 | ||
|
||
def main(): | ||
x = repro() + 5 | ||
print(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
Temporary file until we drop python 3.8 | ||
See https://github.com/pylint-dev/pylint/issues/9751 | ||
Please reunite with used_before_assignment.py at this point | ||
""" | ||
|
||
# pylint: disable=missing-docstring | ||
|
||
import sys | ||
from typing import NoReturn | ||
|
||
|
||
class PlatformChecks: | ||
"""https://github.com/pylint-dev/pylint/issues/9674""" | ||
def skip(self, msg) -> NoReturn: | ||
raise Exception(msg) # pylint: disable=broad-exception-raised | ||
|
||
def print_platform_specific_command(self): | ||
if sys.platform == "linux": | ||
cmd = "ls" | ||
elif sys.platform == "win32": | ||
cmd = "dir" | ||
else: | ||
self.skip("only runs on Linux/Windows") | ||
|
||
print(cmd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[testoptions] | ||
min_pyver=3.9 |