Skip to content

Commit 405a090

Browse files
authored
simplify PYPY check (#703)
1 parent 30ec858 commit 405a090

File tree

3 files changed

+3
-17
lines changed

3 files changed

+3
-17
lines changed

pyflakes/checker.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323
PY35_PLUS = sys.version_info >= (3, 5) # Python 3.5 and above
2424
PY36_PLUS = sys.version_info >= (3, 6) # Python 3.6 and above
2525
PY38_PLUS = sys.version_info >= (3, 8)
26-
try:
27-
sys.pypy_version_info
28-
PYPY = True
29-
except AttributeError:
30-
PYPY = False
26+
PYPY = hasattr(sys, 'pypy_version_info')
3127

3228
builtin_vars = dir(__import__('__builtin__' if PY2 else 'builtins'))
3329

pyflakes/test/test_api.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import subprocess
1010
import tempfile
1111

12+
from pyflakes.checker import PYPY
1213
from pyflakes.messages import UnusedImport
1314
from pyflakes.reporter import Reporter
1415
from pyflakes.api import (
@@ -25,12 +26,6 @@
2526
from io import StringIO
2627
unichr = chr
2728

28-
try:
29-
sys.pypy_version_info
30-
PYPY = True
31-
except AttributeError:
32-
PYPY = False
33-
3429
ERROR_HAS_COL_NUM = ERROR_HAS_LAST_LINE = sys.version_info >= (3, 2) or PYPY
3530

3631

pyflakes/test/test_doctests.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from pyflakes import messages as m
55
from pyflakes.checker import (
6+
PYPY,
67
DoctestScope,
78
FunctionScope,
89
ModuleScope,
@@ -12,12 +13,6 @@
1213
from pyflakes.test.test_undefined_names import Test as TestUndefinedNames
1314
from pyflakes.test.harness import TestCase, skip
1415

15-
try:
16-
sys.pypy_version_info
17-
PYPY = True
18-
except AttributeError:
19-
PYPY = False
20-
2116

2217
class _DoctestMixin(object):
2318

0 commit comments

Comments
 (0)