MCPcopy Create free account
hub / github.com/PyCQA/pyflakes / isPythonFile

Function isPythonFile

pyflakes/api.py:74–93  ·  view source on GitHub ↗

Return True if filename points to a Python file.

(filename)

Source from the content-addressed store, hash-verified

72
73
74def isPythonFile(filename):
75 """Return True if filename points to a Python file."""
76 if filename.endswith('.py'):
77 return True
78
79 # Avoid obvious Emacs backup files
80 if filename.endswith("~"):
81 return False
82
83 max_bytes = 128
84
85 try:
86 with open(filename, 'rb') as f:
87 text = f.read(max_bytes)
88 if not text:
89 return False
90 except OSError:
91 return False
92
93 return PYTHON_SHEBANG_REGEX.match(text)
94
95
96def iterSourceCode(paths):

Callers 1

iterSourceCodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…