Skip to content

Commit

Permalink
begin mypy usage - addresses part of pypa#501
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed Aug 7, 2021
1 parent 407730c commit a85790e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
9 changes: 8 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/asottile/pyupgrade
rev: v2.23.1
rev: v2.23.3
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.17.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.910'
hooks:
- id: mypy
additional_dependencies:
- types-setuptools
- tokenize-rt==3.2.0
9 changes: 9 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[mypy]
python_version = 3.6
warn_return_any = True
warn_unused_configs = True
mypy_path = $MYPY_CONFIG_FILE_DIR/src

[mypy-setuptools_scm.*]
# disabled as it will take a bit
# disallow_untyped_defs = True
2 changes: 1 addition & 1 deletion src/setuptools_scm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools_scm.integration import find_files


def main():
def main() -> None:
print("Guessed Version", get_version())
if "ls" in sys.argv:
for fname in find_files("."):
Expand Down
2 changes: 1 addition & 1 deletion src/setuptools_scm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
except ImportError:
import pkg_resources

Version = pkg_resources.packaging.version.Version
Version = pkg_resources.packaging.version.Version # type: ignore


from .utils import trace
Expand Down
13 changes: 7 additions & 6 deletions src/setuptools_scm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys
import traceback
import warnings

from typing import Optional

DEBUG = bool(os.environ.get("SETUPTOOLS_SCM_DEBUG"))
IS_WINDOWS = platform.system() == "Windows"
Expand All @@ -36,14 +36,15 @@ def no_git_env(env):
}


def trace(*k):
def trace(*k) -> None:
if DEBUG:
print(*k)
sys.stdout.flush()


def trace_exception():
DEBUG and traceback.print_exc()
def trace_exception() -> None:
if DEBUG:
traceback.print_exc()


def ensure_stripped_str(str_or_bytes):
Expand Down Expand Up @@ -144,12 +145,12 @@ def require_command(name):


try:
from importlib.metadata import entry_points
from importlib.metadata import entry_points # type: ignore
except ImportError:
from pkg_resources import iter_entry_points
else:

def iter_entry_points(group, name=None):
def iter_entry_points(group: str, name: Optional[str] = None):
eps = entry_points()[group]
if name is None:
return iter(eps)
Expand Down

0 comments on commit a85790e

Please sign in to comment.