Closed as not planned
Closed as not planned
Description
Bug Report
Some imports in our code only exist if the TYPE_CHECKING
flag is on, but for some reason mypy
doesn't seem to like that.
To Reproduce
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from . import MediaType
class FileFormatError(Exception):
pass
class MediaTypeValueError(FileFormatError):
def __init__(self, value):
super().__init__(f'{value!r} is not a valid media type.')
class UnsupportedFileFormatError(FileFormatError):
def __init__(self, media_type: 'MediaType'):
super().__init__('File is not a supported format.', {'media_type': media_type})
Expected Behaviour
Should be OK.
Actual Behaviour
Deferral trace:
server.misc.file.format.exceptions:4
server.misc.file.format.exceptions:-1
...
server/views/api/home_share/__init__.py: error: INTERNAL ERROR: maximum semantic analysis iteration count reached
Found 1 error in 1 file (errors prevented further checking)
There are thousands more examples throughout the codebase that seem to just be more instances of the same problem in other places. They've been redacted from the above trace; the only one shown is from the To Reproduce example.
Your Environment
- Mypy version used: 0.941
- Mypy command-line flags:
mypy -p server
- Mypy configuration options from
mypy.ini
(and other config files):
mypy_path = $ENCIRCLE_CHECKOUT/server/stubs
plugins = sqlmypy
check_untyped_defs = True
disallow_any_generics = True
disallow_any_unimported = True
disallow_incomplete_defs = True
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_decorators = True
disallow_untyped_defs = True
no_implicit_optional = True
# Disabled until https://github.com/python/mypy/issues/8481 is fixed or if we
# can rid of all `import *` in our codebase
no_implicit_reexport = False
strict_equality = True
warn_redundant_casts = True
warn_return_any = True
warn_unused_ignores = True
- Python version used: 3.9.9
- Operating system and version: macOS Monterey 12.3