-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
Crash Report
mypy crashes with segmentation fault as such:
mypy-segmentation-fault on ξ main is π¦ v0.1.0 via π v3.11.6 (mypy-segmentation-fault-py3.11)
β― mypy --version
mypy 1.7.1 (compiled: yes)
mypy-segmentation-fault on ξ main is π¦ v0.1.0 via π v3.11.6 (mypy-segmentation-fault-py3.11)
β― mypy -p mypy_segmentation_fault
zsh: segmentation fault mypy -p mypy_segmentation_fault
with mypy_segmentation_fault.py
:
from datetime import UTC, datetime
from typing import Protocol, Self
from injector import Binder, Injector, Module
class NowGenerator(Protocol):
def __call__(self: Self) -> datetime:
...
class NowGeneratorImpl:
def __call__(self: Self) -> datetime:
return datetime.now(tz=UTC)
class GeneratorsModule(Module):
def configure(self: Self, binder: Binder) -> None:
binder.bind(
NowGenerator, # type: ignore[type-abstract]
to=NowGeneratorImpl,
)
injector = Injector([GeneratorsModule])
print(injector.get(NowGenerator)()) # type: ignore[type-abstract]
My observation is that if I remove Self
type annotation, mypy does not crash and I do realise it is not necessary
(though, it was a good way to avoid hitting ruff's missing-type-self rule, which in theory I could disable).
I don't know if I could reproduce the crash without using python-injector.
Traceback
Unfortunately, nothing useful shows up:
mypy --show-traceback -p mypy_segmentation_fault
zsh: segmentation fault mypy --show-traceback -p mypy_segmentation_fault
To Reproduce
- Minimum reproducable code: https://github.com/ryo-tagami/mypy-segmentation-fault
- Invoking mypy:
mypy -p mypy_segmentation_fault
Your Environment
- Mypy version used: 1.7.1
- Mypy command-line flags:
-p mypy_segmentation_fault
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used: 3.11.6
- Operating system and version: macOS Sonoma Version 14.1.2 (23B92) on Apple M2 Pro