Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding type hints to be mypy compliant #111

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sdavtaker
Copy link

Description

Describe:

  • This pull request add type-hints for mypy to be able to validate the codebase has not typing issues.

The code was tested by running mypy before and after, there is no behavioural change.

Before:

giturlparse/platforms/base.py:22: error: Need type annotation for "DEFAULTS" (hint: "DEFAULTS: dict[<type>, <type>] = ...")  [var-annotated]
giturlparse/platforms/gitlab.py:31: error: Incompatible types in assignment (expression has type "tuple[str, str]", base class "BasePlatform" defined the type as "None")  [assignment]
giturlparse/platforms/github.py:27: error: Incompatible types in assignment (expression has type "tuple[str, str]", base class "BasePlatform" defined the type as "None")  [assignment]
giturlparse/platforms/friendcode.py:5: error: Incompatible types in assignment (expression has type "tuple[str]", base class "BasePlatform" defined the type as "None")  [assignment]
giturlparse/platforms/bitbucket.py:19: error: Incompatible types in assignment (expression has type "tuple[str]", base class "BasePlatform" defined the type as "None")  [assignment]
giturlparse/platforms/assembla.py:5: error: Incompatible types in assignment (expression has type "tuple[str]", base class "BasePlatform" defined the type as "None")  [assignment]
Found 6 errors in 6 files (checked 15 source files)

After

mypy .                                 
Success: no issues found in 15 source files

To be able to run the checks, mypy and types sub for invoke and setuptools are required.

pip install mypy
pip install types-invoke
pip install types-setuptools

Checklist

  • Code lint checked via inv lint
  • [-] Tests added

No test added since its not adding functionallity.
I was not able to run inv lint, neither precommit. I run into some issues trying to run it, I will open a Issue about it.

I also tried to follow the format specified here for the commit and changes in the changes file but couldn't understand where should I get the from.
If you can guide me a little I can update the PR to adhere to the convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant