christophebedard / dco-check

Simple DCO check script to be used in any CI
Apache License 2.0
12 stars 6 forks source link

Mypy detects several possible type errors #95

Closed zyga closed 3 years ago

zyga commented 3 years ago

Since the projects has several type annotations I decided to run mypy on it to see what it reports.

zyga@superfx:~/git/dco-check$ mypy .
setup.py:15: error: No library stub file for module 'setuptools'
setup.py:15: note: (Stub files are from https://github.com/python/typeshed)
dco_check/dco_check.py:288: error: Incompatible return value type (got "Optional[Match[str]]", expected "bool")
dco_check/dco_check.py:568: error: Argument 1 to "split_commits_data" has incompatible type "Optional[str]"; expected "str"
dco_check/dco_check.py:587: error: Argument 4 to "CommitInfo" has incompatible type "Optional[str]"; expected "str"
dco_check/dco_check.py:588: error: Argument 5 to "CommitInfo" has incompatible type "Optional[str]"; expected "str"
dco_check/dco_check.py:661: error: Argument 1 to "fetch_branch" has incompatible type "Optional[str]"; expected "str"
dco_check/dco_check.py:906: error: Unsupported operand types for + ("str" and "None")
dco_check/dco_check.py:906: note: Right operand is of type "Optional[str]"
dco_check/dco_check.py:913: error: "pprint" does not return a value
dco_check/dco_check.py:990: error: 'None' object is not iterable
dco_check/dco_check.py:1065: error: Item "None" of "Optional[CommitDataRetriever]" has no attribute "name"
dco_check/dco_check.py:1077: error: Item "None" of "Optional[CommitDataRetriever]" has no attribute "get_commit_range"
dco_check/dco_check.py:1092: error: Item "None" of "Optional[CommitDataRetriever]" has no attribute "get_commits"
Found 12 errors in 2 files (checked 3 source files)

It seems most of those can be reduced to missing None checks.