-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mypy: even more strict #2241
mypy: even more strict #2241
Conversation
[tool.mypy] | ||
python_version = "3.10" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't particularly useful, what we really need is python/mypy#12286
@@ -473,7 +477,7 @@ def merge_samples(samples: Iterable[dict[Any, Any]]) -> dict[Any, Any]: | |||
return collated | |||
|
|||
|
|||
def unbind_samples(sample: dict[Any, Sequence[Any]]) -> list[dict[Any, Any]]: | |||
def unbind_samples(sample: MutableMapping[Any, Any]) -> list[dict[Any, Any]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be a sequence, this was a bug
@@ -99,7 +99,7 @@ def forward(self, batch: dict[str, Tensor]) -> dict[str, Tensor]: | |||
|
|||
# Convert boxes to default [N, 4] | |||
if 'boxes' in batch: | |||
batch['boxes'] = Boxes(batch['boxes']).to_tensor(mode='xyxy') # type:ignore[assignment] | |||
batch['boxes'] = Boxes(batch['boxes']).to_tensor(mode='xyxy') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bug was introduced in #1082
Adds additional checks like
warn_unreachable
that revealed new bugs. And fixes those bugs!I also played around with generics like:
but ran into too many issues and gave up. Maybe another day.