python-attrs / cattrs

Composable custom class converters for attrs, dataclasses and friends.
https://catt.rs
MIT License
799 stars 111 forks source link

Make `BaseValidationError` base static in Python < 3.11 #379

Closed layday closed 1 year ago

layday commented 1 year ago

Unsure if this worked in MyPy but Pyright failed to resolve the base of BaseValidationError subclasses leading to hard to trace type errors in custom note attributes from failing to narrow Iterable and ClassValidationError unions.

layday commented 1 year ago

Because str.index exists and it's a function on AttributeValidationNote iso of the IterableValidationNote's str | int, Pyright would expand note.index to ((__sub: str, __start: SupportsIndex | None = ..., __end: SupportsIndex | None = ..., /) -> int) | int | str 🙈

codecov-commenter commented 1 year ago

Codecov Report

Merging #379 (356b82c) into main (116d25b) will decrease coverage by 1.42%. The diff coverage is 100.00%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main     #379      +/-   ##
==========================================
- Coverage   95.80%   94.38%   -1.42%     
==========================================
  Files          26       26              
  Lines        2121     2120       -1     
==========================================
- Hits         2032     2001      -31     
- Misses         89      119      +30     
Impacted Files Coverage Δ
src/cattrs/_compat.py 95.17% <100.00%> (-0.90%) :arrow_down:

... and 2 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

Tinche commented 1 year ago

Cool, thanks!