Skip to content

Commit

Permalink
chore(typing): add more descriptive typing to Context (#2226)
Browse files Browse the repository at this point in the history
* chore(typing): add more descriptive typing to `Context`

* chore(typing): define only stubs when under `TYPE_CHECKING`
  • Loading branch information
vytas7 committed Apr 5, 2024
1 parent 7ec1d31 commit 64af3cf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions falcon/util/structures.py
Expand Up @@ -37,6 +37,7 @@
from typing import KeysView
from typing import Optional
from typing import Tuple
from typing import TYPE_CHECKING
from typing import ValuesView


Expand Down Expand Up @@ -141,6 +142,19 @@ class Context:
True
"""

# NOTE(vytas): Define synthetic attr access methods (under TYPE_CHECKING)
# merely to let mypy know this is a namespace object.
if TYPE_CHECKING:

def __getattr__(self, name: str) -> Any:
...

def __setattr__(self, name: str, value: Any) -> None:
...

def __delattr__(self, name: str) -> None:
...

def __contains__(self, key: str) -> bool:
return self.__dict__.__contains__(key)

Expand Down

0 comments on commit 64af3cf

Please sign in to comment.