Skip to content

Commit

Permalink
Deobfuscate cursed code so Mypy can understand it
Browse files Browse the repository at this point in the history
I suppose it'll be easier for people too.
  • Loading branch information
mgedmin committed Jul 22, 2024
1 parent 36131bc commit 243506a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/check_python_versions/parsers/poetry_version_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""

import re
from functools import partial
from typing import Callable, Dict, List, Optional, Tuple, Union

from ..utils import warn
Expand Down Expand Up @@ -61,7 +60,11 @@ class BadConstraint(Exception):
#

handlers: Dict[str, HandlerFn] = {}
handler = partial(partial, handlers.__setitem__)

def handler(operator: str) -> Callable[[HandlerFn], None]:
def decorator(fn: HandlerFn) -> None:
handlers[operator] = fn
return decorator

#
# We are not doing a strict version check here because if the spec says,
Expand Down
7 changes: 5 additions & 2 deletions src/check_python_versions/parsers/requires_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Tools for manipulating requires-python PyPI classifiers.
"""
import re
from functools import partial
from typing import Callable, Dict, List, Optional, Tuple, Union

from ..utils import warn
Expand Down Expand Up @@ -58,7 +57,11 @@ class BadConstraint(Exception):
#

handlers: Dict[str, HandlerFn] = {}
handler = partial(partial, handlers.__setitem__)

def handler(operator: str) -> Callable[[HandlerFn], None]:
def decorator(fn: HandlerFn) -> None:
handlers[operator] = fn
return decorator

#
# We are not doing a strict PEP-440 implementation here because if
Expand Down

0 comments on commit 243506a

Please sign in to comment.