Skip to content

Commit

Permalink
burn the bridges with python 2.x (#707)
Browse files Browse the repository at this point in the history
* pyupgrade --py36-plus

* remove handling of PY2

* remove handling of PY35_PLUS

* remove handling of PY36_PLUS

* remove obsolete version_info checks in pyflakes/

* adjust skips in tests for 3.6+

* is_py3_func -> has_annotations (specifically for lambda)

* remove references to py 2

* remove references to unichr

* clean up version-specific getattrs

* remove unused ReturnWithArgsInsideGenerator

* remove unused ast handlers

* remove unused RedefinedInListComp
  • Loading branch information
asottile committed Jun 12, 2022
1 parent becbab6 commit 2246217
Show file tree
Hide file tree
Showing 17 changed files with 203 additions and 639 deletions.
8 changes: 4 additions & 4 deletions pyflakes/api.py
Expand Up @@ -12,7 +12,7 @@

__all__ = ['check', 'checkPath', 'checkRecursive', 'iterSourceCode', 'main']

PYTHON_SHEBANG_REGEX = re.compile(br'^#!.*\bpython([23](\.\d+)?|w)?[dmu]?\s')
PYTHON_SHEBANG_REGEX = re.compile(br'^#!.*\bpython(3(\.\d+)?|w)?[dmu]?\s')


def check(codeString, filename, reporter=None):
Expand Down Expand Up @@ -48,7 +48,7 @@ def check(codeString, filename, reporter=None):
lines = codeString.splitlines()
if len(lines) >= lineno:
text = lines[lineno - 1]
if sys.version_info >= (3, ) and isinstance(text, bytes):
if isinstance(text, bytes):
try:
text = text.decode('ascii')
except UnicodeDecodeError:
Expand Down Expand Up @@ -90,7 +90,7 @@ def checkPath(filename, reporter=None):
try:
with open(filename, 'rb') as f:
codestr = f.read()
except IOError:
except OSError:
msg = sys.exc_info()[1]
reporter.unexpectedError(filename, msg.args[1])
return 1
Expand All @@ -113,7 +113,7 @@ def isPythonFile(filename):
text = f.read(max_bytes)
if not text:
return False
except IOError:
except OSError:
return False

return PYTHON_SHEBANG_REGEX.match(text)
Expand Down

0 comments on commit 2246217

Please sign in to comment.