-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
Repro
In file.py:
import otherIn other (no file extension):
#!/bin/sh
echo syntax errorRunning:
$ mypy file.py
other:3: error: invalid syntax [syntax]
Found 1 error in 1 file (errors prevented further checking)
When running in CPython, you get this:
$ python file.py
Traceback (most recent call last):
File "file.py", line 1, in <module>
import other
ModuleNotFoundError: No module named 'other'
So I would expect Mypy to return either a "module not found" error or a "this is not a python file" error instead actually parsing other as a Python file. From reading the docs it would seem that the other module should only be importable from other.py[i] or other/__init__.py[i], but not a file called other.
I found this while running Mypy on beartype which has shell files called pytest and sphinx in the root directory, which causes Mypy to import the shell scripts if pytest or sphinx is not installed.
Environment
$ mypy --version
mypy 0.991 (compiled: yes)
$ python --version
Python 3.10.9
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong