-
-
Notifications
You must be signed in to change notification settings - Fork 291
Closed
Description
The method enable_packrat
has a type annotation for cache_size_limit: int
, as well as a default value of 128
:
Line 1082 in d5aafc3
def enable_packrat(cache_size_limit: int = 128, *, force: bool = False) -> None: |
However, the method's docstring and implementation indicate that passing None
will lead to an unbounded cache:
Lines 1119 to 1120 in d5aafc3
if cache_size_limit is None: | |
ParserElement.packrat_cache = _UnboundedCache() |
In a downstream project, we'd like to be able to pass None
, and also use a typechecker to check our project. Currently, this doesn't seems possible. For example, mypy will say:
pydevicetree/source/grammar.py:23: error: Argument 1 to "enable_packrat" of "ParserElement" has incompatible type "int | None"; expected "int" [arg-type]
It seems like a simple update to the type annotation of enable_packrat
. I'm happy to send a PR for that.
Metadata
Metadata
Assignees
Labels
No labels