Skip to content

feat: Add mypy configuration file #4315

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

Merged
merged 3 commits into from
Apr 6, 2021

Conversation

dhruvmanila
Copy link
Member

Describe your change:

  • New feature
  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@dhruvmanila dhruvmanila requested a review from cclauss as a code owner April 5, 2021 09:11
@ghost ghost added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Apr 5, 2021
Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we only run mypy in our GitHub Action then I would be opposed to storing configuration in two separate files. However if we add mypy to https://github.com/TheAlgorithms/Python/blob/master/.pre-commit-config.yaml then I would be in favor of this change.

@dhruvmanila
Copy link
Member Author

dhruvmanila commented Apr 5, 2021

For now, we are only using ignore-missing-imports flag which is available for the CLI mypy but some flags are not available and as we get more stricter in the future we would need to have additional flags and I would prefer it to be added in its own configuration file.

Also, when we test mypy locally we would not need to pass any flags and directly run mypy as: $ mypy . which is better and shorter to type than $ mypy --ignore-missing-imports --warn-unused-imports --disallow-untyped-defs ...

I would be opposed to storing configuration in two separate files.

We will be storing configuration only in one file, mypy will pick it up when we run mypy . in CI.

This also has the added benefit to fine tune mypy as per the directory which is a possible scenario in the future.

The problem with running mypy in pre-commit is that pre-commit runs every hook in its own virtual environment and as mypy needs the information from project dependencies, they need to be installed there as well. pre-commit does provide an option: - additional_dependencies: ['numpy', ...] but that would mean we need to maintain the dependencies in requirements.txt and in pre-commit-config.yaml.

@dhruvmanila
Copy link
Member Author

Hmm, weird. It seems that all of the builds are stuck from my last commit to master: https://github.com/TheAlgorithms/Python/actions

@cclauss
Copy link
Member

cclauss commented Apr 5, 2021

Something strange is happening...

@dhruvmanila
Copy link
Member Author

I have reported to GitHub. Lets see what's going on.

Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ghost ghost removed the awaiting reviews This PR is ready to be reviewed label Apr 6, 2021
@cclauss cclauss merged commit c49fa08 into TheAlgorithms:master Apr 6, 2021
algobytewise pushed a commit to algobytewise/Python that referenced this pull request Apr 6, 2021
* feat: Add mypy config file

* refactor: Remove mypy options from build workflow

* Remove linear_algebra

Co-authored-by: Christian Clauss <[email protected]>
cclauss added a commit that referenced this pull request Apr 6, 2021
* fix type-hints arguments

* fix matrices & image-path

* Update build.yml

* Revert "Update build.yml"

This reverts commit c2d04ae.

* use pathlib

* feat: Add mypy configuration file (#4315)

* feat: Add mypy config file

* refactor: Remove mypy options from build workflow

* Remove linear_algebra

Co-authored-by: Christian Clauss <[email protected]>

* rebase & update mypy.ini

* fix pre-commit errors

Co-authored-by: Dhruv Manilawala <[email protected]>
Co-authored-by: Christian Clauss <[email protected]>
@dhruvmanila dhruvmanila mentioned this pull request Apr 7, 2021
15 tasks
Panquesito7 pushed a commit to Panquesito7/Python that referenced this pull request May 13, 2021
* feat: Add mypy config file

* refactor: Remove mypy options from build workflow

* Remove linear_algebra

Co-authored-by: Christian Clauss <[email protected]>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this pull request May 13, 2021
* fix type-hints arguments

* fix matrices & image-path

* Update build.yml

* Revert "Update build.yml"

This reverts commit c2d04ae.

* use pathlib

* feat: Add mypy configuration file (TheAlgorithms#4315)

* feat: Add mypy config file

* refactor: Remove mypy options from build workflow

* Remove linear_algebra

Co-authored-by: Christian Clauss <[email protected]>

* rebase & update mypy.ini

* fix pre-commit errors

Co-authored-by: Dhruv Manilawala <[email protected]>
Co-authored-by: Christian Clauss <[email protected]>
shermanhui pushed a commit to shermanhui/Python that referenced this pull request Oct 22, 2021
* feat: Add mypy config file

* refactor: Remove mypy options from build workflow

* Remove linear_algebra

Co-authored-by: Christian Clauss <[email protected]>
shermanhui pushed a commit to shermanhui/Python that referenced this pull request Oct 22, 2021
* fix type-hints arguments

* fix matrices & image-path

* Update build.yml

* Revert "Update build.yml"

This reverts commit c2d04ae.

* use pathlib

* feat: Add mypy configuration file (TheAlgorithms#4315)

* feat: Add mypy config file

* refactor: Remove mypy options from build workflow

* Remove linear_algebra

Co-authored-by: Christian Clauss <[email protected]>

* rebase & update mypy.ini

* fix pre-commit errors

Co-authored-by: Dhruv Manilawala <[email protected]>
Co-authored-by: Christian Clauss <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This PR modified some existing files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants