status.__getattr__ breaks static typing #3184
Replies: 1 comment
-
|
This looks like a typing issue rather than a runtime behavior issue. The dynamic A fix would need to preserve the deprecated alias behavior while narrowing the type surface. A stub file or overloads for the known deprecated names would be safer than simply removing |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Howdy! Just noticed this.
The
statusmodule has a__getattr__(...) -> int:definition which means that type checking tools (mypy in my case) won't flag invalid attributes.This is a runtime error but type-checks fine.
It's a bit pernicious in that a lot of the status codes are only accessed in failure cases and are less likely to be tested.
The reason for the
__getattr__is to raise aDeprecationWarningon accessing some deprecated statuses (like Unprocessable Entity instead of Unprocessable Content). Could the typing be better? Or is there a different way to raise theDeprecationWarning?Beta Was this translation helpful? Give feedback.
All reactions