Skip to content

Commit

Permalink
Merge pull request #139 from neutrinoceros/future_annotations
Browse files Browse the repository at this point in the history
ENH: upgrade type annotations
  • Loading branch information
neutrinoceros authored Oct 5, 2021
2 parents 2336fcc + ea80be1 commit ea875d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ omit = [
"install_app.py",
"tests/data/*.py",
]

[tool.mypy]
python_version = "3.7"
12 changes: 6 additions & 6 deletions wxc/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import builtins
import inspect
import re
Expand All @@ -8,8 +10,6 @@
from platform import python_version
from types import BuiltinFunctionType
from typing import Any
from typing import Dict
from typing import List

if sys.version_info < (3, 8):
import importlib_metadata as md
Expand Down Expand Up @@ -51,9 +51,9 @@ def get_builtin_obj(name: str):


def get_suggestions(
candidates: List[str], target: str, *, max_dist: int = sys.maxsize
) -> List[str]:
suggestions: Dict[int, List[str]] = defaultdict(list)
candidates: list[str], target: str, *, max_dist: int = sys.maxsize
) -> list[str]:
suggestions: dict[int, list[str]] = defaultdict(list)
minimal_distance: int = max_dist
for a in candidates:
d: int = levenshtein_distance(target, a, max_dist=minimal_distance)
Expand All @@ -64,7 +64,7 @@ def get_suggestions(


@lru_cache(maxsize=128)
def get_objects(name: str) -> List[Any]:
def get_objects(name: str) -> list[Any]:
if is_builtin(name):
return [get_builtin_obj(name)]

Expand Down
6 changes: 3 additions & 3 deletions wxc/cli.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

import inspect
import sys
from argparse import ArgumentParser
from typing import List
from typing import Optional

from rich.progress import Progress
from rich.progress import SpinnerColumn
Expand All @@ -29,7 +29,7 @@ def __new__(cls, content):
return str.__new__(cls, content.replace("-", "_"))


def main(argv: Optional[List[str]] = None) -> int:
def main(argv: list[str] | None = None) -> int:
parser = ArgumentParser()
parser.add_argument(
"name",
Expand Down

0 comments on commit ea875d8

Please sign in to comment.