Skip to content

Python: Fix ty 0.0.18 type checking diagnostics#6806

Merged
knutwannheden merged 1 commit intomainfrom
bold-viper
Feb 24, 2026
Merged

Python: Fix ty 0.0.18 type checking diagnostics#6806
knutwannheden merged 1 commit intomainfrom
bold-viper

Conversation

@knutwannheden
Copy link
Contributor

Summary

  • Add targeted # ty: ignore suppressions with issue references for known ty limitations and structural Python constraints
  • Add replace() method declaration to J base class in .pyi stub, fixing ~20 unresolved-attribute errors where frozen dataclass replace() was not visible on abstract base types
  • Add @dataclass decorator to Union and Intersection in .pyi stub, fixing 5 unknown-argument errors for _bounds parameter
  • Remove obsolete # ty: ignore comments that are no longer needed with ty 0.0.18
  • Add per-line suppressions referencing upstream ty issues (ty#628, ty#2193) where applicable

28 diagnostics remain in type_mapping.py — these are due to a structural Python limitation where JavaType inner classes cannot extend the enclosing JavaType class (metaclass conflict between ABCMeta and EnumMeta for Primitive).

Test plan

  • All 997 existing tests pass
  • ty check shows 0 new diagnostics (28 remaining are pre-existing type_mapping.py limitation)
  • No semantic changes — all modifications are type annotation/suppression only

Add targeted `# ty: ignore` suppressions with issue references for
known ty limitations and structural Python constraints. Key changes:

- Add `replace()` to `J` base class in `.pyi` stub (fixes ~20 errors)
- Add `@dataclass` to `Union`/`Intersection` in stubs (fixes 5 errors)
- Remove obsolete `# ty: ignore` comments no longer needed
- Add per-line suppressions referencing ty#628, ty#2193 where applicable

28 diagnostics remain in `type_mapping.py` due to JavaType inner class
hierarchy not being expressible in Python (metaclass conflict between
ABC and Enum prevents inner classes from extending enclosing class).
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Feb 24, 2026
@knutwannheden knutwannheden merged commit cc39339 into main Feb 24, 2026
1 check passed
@knutwannheden knutwannheden deleted the bold-viper branch February 24, 2026 13:30
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant