Skip to content

Commit

Permalink
Add type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
thombashi committed Oct 7, 2023
1 parent ffc7e64 commit 7097c76
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
20 changes: 10 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import os.path
from typing import Dict
from typing import Dict, Final, List, Type

import setuptools


MODULE_NAME = "tblfaker"
REPOSITORY_URL = f"https://github.com/thombashi/{MODULE_NAME:s}"
REQUIREMENT_DIR = "requirements"
ENCODING = "utf8"
MODULE_NAME: Final = "tblfaker"
REPOSITORY_URL: Final = f"https://github.com/thombashi/{MODULE_NAME:s}"
REQUIREMENT_DIR: Final = "requirements"
ENCODING: Final = "utf8"

pkg_info = {} # type: Dict[str, str]
pkg_info: Dict[str, str] = {}


def get_release_command_class() -> Dict[str, setuptools.Command]:
def get_release_command_class() -> Dict[str, Type[setuptools.Command]]:
try:
from releasecmd import ReleaseCommand
except ImportError:
Expand All @@ -25,13 +25,13 @@ def get_release_command_class() -> Dict[str, setuptools.Command]:
exec(f.read(), pkg_info)

with open("README.rst", encoding=ENCODING) as f:
LONG_DESCRIPTION = f.read()
LONG_DESCRIPTION: Final[str] = f.read()

with open(os.path.join(REQUIREMENT_DIR, "requirements.txt")) as f:
INSTALL_REQUIRES = [line.strip() for line in f if line.strip()]
INSTALL_REQUIRES: Final[List[str]] = [line.strip() for line in f if line.strip()]

with open(os.path.join(REQUIREMENT_DIR, "test_requirements.txt")) as f:
TESTS_REQUIRES = [line.strip() for line in f if line.strip()]
TESTS_REQUIRES: Final[List[str]] = [line.strip() for line in f if line.strip()]

setuptools.setup(
name=MODULE_NAME,
Expand Down
15 changes: 9 additions & 6 deletions tblfaker/__version__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
__author__ = "Tsuyoshi Hombashi"
__copyright__ = f"Copyright 2018, {__author__}"
__license__ = "MIT License"
__version__ = "0.2.4"
__maintainer__ = __author__
__email__ = "tsuyoshi.hombashi@gmail.com"
from typing import Final


__author__: Final = "Tsuyoshi Hombashi"
__copyright__: Final = f"Copyright 2018, {__author__}"
__license__: Final = "MIT License"
__version__: Final = "0.2.4"
__maintainer__: Final = __author__
__email__: Final = "tsuyoshi.hombashi@gmail.com"
10 changes: 5 additions & 5 deletions tblfaker/_common.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import inspect
import re
from typing import AbstractSet, Sequence
from typing import AbstractSet, Final, Sequence

from faker import Factory


_non_provider_regexp = re.compile("^(add|del|get|set)_[a-z_]+")
_non_provider_methods = (
_non_provider_regexp: Final = re.compile("^(add|del|get|set)_[a-z_]+")
_non_provider_methods: Final = (
"__init__",
"_Generator__format_token",
"format",
Expand All @@ -24,8 +24,8 @@ def _get_valid_providers() -> Sequence[str]:
)


_valid_providers = frozenset(_get_valid_providers())
_valid_locals = frozenset(
_valid_providers: Final = frozenset(_get_valid_providers())
_valid_locals: Final = frozenset(
[
"ar_EG",
"ar_PS",
Expand Down

0 comments on commit 7097c76

Please sign in to comment.