Skip to content

Conversation

sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Jun 26, 2025

Summary

Format conflicting declared types as

`str`, `int` and `bytes`

Thanks to @AlexWaygood for the initial draft.

@dcreager, looking forward to your one-character follow-up PR.

@sharkdp sharkdp added internal An internal refactor or improvement ty Multi-file analysis & type inference diagnostics Related to reporting of diagnostics. labels Jun 26, 2025
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! There might be some pre-existing diagnostics that could also make use of this

Copy link
Contributor

github-actions bot commented Jun 26, 2025

mypy_primer results

Changes were detected when running on open source projects
pydantic (https://github.com/pydantic/pydantic)
- error[conflicting-declarations] pydantic/v1/schema.py:1143:17: Conflicting declared types for `constraint_func`: ((...) -> type) | None, def constraint_func(**kw: Any) -> type[Any], def constraint_func(**kw: Any) -> type[Any], def constraint_func(**kw: Any) -> type[Any]
+ error[conflicting-declarations] pydantic/v1/schema.py:1143:17: Conflicting declared types for `constraint_func`: `((...) -> type) | None`, `def constraint_func(**kw: Any) -> type[Any]`, `def constraint_func(**kw: Any) -> type[Any]` and `def constraint_func(**kw: Any) -> type[Any]`

cloud-init (https://github.com/canonical/cloud-init)
- error[conflicting-declarations] cloudinit/handlers/jinja_template.py:28:5: Conflicting declared types for `JUndefinedError`: type[Exception], <class 'UndefinedError'>
+ error[conflicting-declarations] cloudinit/handlers/jinja_template.py:28:5: Conflicting declared types for `JUndefinedError`: `type[Exception]` and `<class 'UndefinedError'>`

typeshed-stats (https://github.com/AlexWaygood/typeshed-stats)
- error[conflicting-declarations] src/typeshed_stats/_cli.py:83:17: Conflicting declared types for `pprint`: (object, /) -> None, Unknown
+ error[conflicting-declarations] src/typeshed_stats/_cli.py:83:17: Conflicting declared types for `pprint`: `(object, /) -> None` and `Unknown`

vision (https://github.com/pytorch/vision)
- error[conflicting-declarations] torchvision/datasets/folder.py:80:5: Conflicting declared types for `is_valid_file`: ((str, /) -> bool) | None, def is_valid_file(x: str) -> bool
+ error[conflicting-declarations] torchvision/datasets/folder.py:80:5: Conflicting declared types for `is_valid_file`: `((str, /) -> bool) | None` and `def is_valid_file(x: str) -> bool`

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- error[conflicting-declarations] benchmarks/appsec_iast_aspects/scenario.py:25:13: Conflicting declared types for `set_iast_request_enabled`: def set_iast_request_enabled(request_enabled) -> None, Unknown
+ error[conflicting-declarations] benchmarks/appsec_iast_aspects/scenario.py:25:13: Conflicting declared types for `set_iast_request_enabled`: `def set_iast_request_enabled(request_enabled) -> None` and `Unknown`
- error[conflicting-declarations] benchmarks/appsec_iast_aspects_ospath/scenario.py:23:13: Conflicting declared types for `set_iast_request_enabled`: def set_iast_request_enabled(request_enabled) -> None, Unknown
+ error[conflicting-declarations] benchmarks/appsec_iast_aspects_ospath/scenario.py:23:13: Conflicting declared types for `set_iast_request_enabled`: `def set_iast_request_enabled(request_enabled) -> None` and `Unknown`
- error[conflicting-declarations] benchmarks/appsec_iast_aspects_re_module/scenario.py:23:13: Conflicting declared types for `set_iast_request_enabled`: def set_iast_request_enabled(request_enabled) -> None, Unknown
+ error[conflicting-declarations] benchmarks/appsec_iast_aspects_re_module/scenario.py:23:13: Conflicting declared types for `set_iast_request_enabled`: `def set_iast_request_enabled(request_enabled) -> None` and `Unknown`
- error[conflicting-declarations] benchmarks/appsec_iast_aspects_split/scenario.py:23:13: Conflicting declared types for `set_iast_request_enabled`: def set_iast_request_enabled(request_enabled) -> None, Unknown
+ error[conflicting-declarations] benchmarks/appsec_iast_aspects_split/scenario.py:23:13: Conflicting declared types for `set_iast_request_enabled`: `def set_iast_request_enabled(request_enabled) -> None` and `Unknown`
- error[conflicting-declarations] benchmarks/appsec_iast_propagation/scenario.py:20:9: Conflicting declared types for `set_iast_request_enabled`: def set_iast_request_enabled(request_enabled) -> None, Unknown
+ error[conflicting-declarations] benchmarks/appsec_iast_propagation/scenario.py:20:9: Conflicting declared types for `set_iast_request_enabled`: `def set_iast_request_enabled(request_enabled) -> None` and `Unknown`

@sharkdp sharkdp requested a review from MichaReiser as a code owner June 26, 2025 12:23
@sharkdp
Copy link
Contributor Author

sharkdp commented Jun 26, 2025

Nice! There might be some pre-existing diagnostics that could also make use of this

Nothing immediately came up while doing a superficial scan.

@sharkdp sharkdp merged commit 86fd9b6 into main Jun 26, 2025
35 checks passed
@sharkdp sharkdp deleted the david/human-readable-enumeration branch June 26, 2025 12:29
dcreager added a commit that referenced this pull request Jun 26, 2025
* main:
  [ty] Add regression-benchmark for attribute-assignment hang (#18957)
  [ty] Format conflicting types as an enumeration (#18956)
  [ty] Prevent union builder construction for just one declaration (#18954)
  [ty] Infer nonlocal types as unions of all reachable bindings (#18750)
  [`pyflakes`] Mark `F504`/`F522`/`F523` autofix as unsafe if there's a call with side effect (#18839)
  [`playground`] Add ruff logo docs link to Header.tsx (#18947)
  [ty] Reduce the overwhelming complexity of `TypeInferenceBuilder::infer_call_expression` (#18943)
  [ty] Add subdiagnostic about empty bodies in more cases (#18942)
  [ty] Move search path resolution to `Options::to_program_settings` (#18937)
  [`flake8-errmsg`] Extend `EM101` to support byte strings (#18867)
  Move big rule implementations (#18931)
  [`pylint`] Allow fix with comments and document performance implications (`PLW3301`) (#18936)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostics Related to reporting of diagnostics. internal An internal refactor or improvement ty Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants