Skip to content

Conversation

@sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Apr 28, 2025

Summary

Do not emit errors when accessing introspection dunder attributes such as __required_keys__ on TypedDicts.

@sharkdp sharkdp added the ty Multi-file analysis & type inference label Apr 28, 2025
@github-actions
Copy link
Contributor

mypy_primer results

Changes were detected when running on open source projects
kopf (https://github.com/nolar/kopf)
- error[lint:invalid-assignment] /tmp/mypy_primer/projects/kopf/kopf/_cogs/clients/creating.py:21:5: Object of type `dict` is not assignable to `RawBody | None`
+ error[lint:invalid-assignment] /tmp/mypy_primer/projects/kopf/kopf/_cogs/clients/creating.py:21:5: Object of type `RawBody | dict` is not assignable to `RawBody | None`
- error[lint:invalid-argument-type] /tmp/mypy_primer/projects/kopf/kopf/_core/reactor/processing.py:443:81: Argument to this function is incorrect: Expected `BodyEssence`, found `BodyEssence | None`
+ error[lint:invalid-argument-type] /tmp/mypy_primer/projects/kopf/kopf/_core/reactor/processing.py:443:81: Argument to this function is incorrect: Expected `BodyEssence`, found `@Todo(TypedDict) | None`

pydantic (https://github.com/pydantic/pydantic)
+ warning[lint:unused-ignore-comment] /tmp/mypy_primer/projects/pydantic/pydantic/json_schema.py:529:44: Unused blanket `type: ignore` directive
+ warning[lint:unused-ignore-comment] /tmp/mypy_primer/projects/pydantic/pydantic/json_schema.py:1554:54: Unused blanket `type: ignore` directive
+ warning[lint:unused-ignore-comment] /tmp/mypy_primer/projects/pydantic/pydantic/json_schema.py:1556:49: Unused blanket `type: ignore` directive
- Found 913 diagnostics
+ Found 916 diagnostics

scrapy (https://github.com/scrapy/scrapy)
+ warning[lint:unused-ignore-comment] /tmp/mypy_primer/projects/scrapy/scrapy/pipelines/media.py:250:36: Unused blanket `type: ignore` directive
- warning[lint:possibly-unbound-attribute] /tmp/mypy_primer/projects/scrapy/scrapy/pipelines/media.py:247:13: Attribute `cleanFailure` on type `FileInfo | Unknown` is possibly unbound
- error[lint:invalid-assignment] /tmp/mypy_primer/projects/scrapy/scrapy/pipelines/media.py:248:13: Object of type `list` is not assignable to attribute `frames` on type `FileInfo | Unknown`
- warning[lint:possibly-unbound-attribute] /tmp/mypy_primer/projects/scrapy/scrapy/pipelines/media.py:269:31: Attribute `value` on type `FileInfo | Unknown` is possibly unbound
- warning[lint:possibly-unbound-attribute] /tmp/mypy_primer/projects/scrapy/scrapy/pipelines/media.py:271:17: Attribute `value` on type `FileInfo | Unknown` is possibly unbound
- error[lint:invalid-return-type] /tmp/mypy_primer/projects/scrapy/scrapy/utils/log.py:245:12: Return type does not match returned value: Expected `tuple[int, str, @Todo(specialized non-generic class)]`, found `tuple[@Todo(Support for `typing.TypeVar` instances in type expressions) | None, (@Todo(Support for `typing.TypeVar` instances in type expressions) & ~AlwaysFalsy) | Literal[""], @Todo(specialized non-generic class)]`
- Found 1489 diagnostics
+ Found 1485 diagnostics

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- error[lint:unresolved-attribute] /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/structured_configs/_utils.py:262:5: Type `Literal[DataclassOptions]` has no attribute `__required_keys__`
- error[lint:unresolved-attribute] /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/structured_configs/_utils.py:262:42: Type `Literal[DataclassOptions]` has no attribute `__optional_keys__`
- error[lint:unresolved-attribute] /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/structured_configs/_utils.py:266:5: Type `Literal[StrictDataclassOptions]` has no attribute `__required_keys__`
- error[lint:unresolved-attribute] /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/structured_configs/_utils.py:266:48: Type `Literal[StrictDataclassOptions]` has no attribute `__optional_keys__`
- error[lint:unresolved-attribute] /tmp/mypy_primer/projects/hydra-zen/src/hydra_zen/structured_configs/_utils.py:385:13: Type `Literal[StrictDataclassOptions]` has no attribute `__required_keys__`
- Found 630 diagnostics
+ Found 625 diagnostics

bokeh (https://github.com/bokeh/bokeh)
- error[lint:non-subscriptable] /tmp/mypy_primer/projects/bokeh/src/bokeh/_specs.pyi:72:49: Cannot subscript object of type `UnionType` with no `__getitem__` method
- Found 1854 diagnostics
+ Found 1853 diagnostics

@sharkdp sharkdp marked this pull request as ready for review April 28, 2025 11:22
@sharkdp sharkdp merged commit 92f95ff into main Apr 28, 2025
34 checks passed
@sharkdp sharkdp deleted the david/typed-dict-attributes branch April 28, 2025 11:28
dcreager added a commit that referenced this pull request Apr 28, 2025
* main: (37 commits)
  [red-knot] Revert blanket `clippy::too_many_arguments` allow (#17688)
  Add config option to disable `typing_extensions` imports  (#17611)
  ruff_db: render file paths in diagnostics as relative paths if possible
  Bump mypy_primer pin (#17685)
  red_knot_python_semantic: improve `not-iterable` diagnostic
  [red-knot] Allow all callables to be assignable to @Todo-signatures (#17680)
  [`refurb`] Mark fix as safe for `readlines-in-for` (`FURB129`) (#17644)
  Collect preview lint behaviors in separate module (#17646)
  Upgrade Salsa to a more recent commit (#17678)
  [red-knot] TypedDict: No errors for introspection dunder attributes (#17677)
  [`flake8-pyi`] Ensure `Literal[None,] | Literal[None,]` is not autofixed to `None | None` (`PYI061`) (#17659)
  [red-knot] No errors for definitions of `TypedDict`s (#17674)
  Update actions/download-artifact digest to d3f86a1 (#17664)
  [red-knot] Use 101 exit code when there's at least one diagnostic with severity 'fatal' (#17640)
  [`pycodestyle`] Fix duplicated diagnostic in `E712` (#17651)
  [airflow] fix typos `AIR312` (#17673)
  [red-knot] Don't ignore hidden files by default (#17655)
  Update pre-commit hook astral-sh/ruff-pre-commit to v0.11.7 (#17670)
  Update docker/build-push-action digest to 14487ce (#17665)
  Update taiki-e/install-action digest to ab3728c (#17666)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants