Repository navigation
[mypy] Need help to fix all mypy errors in the codebase #4052
Description
Activity
- pinned this issue
on Dec 27, 2020 @dhruvmanila I am beginner programmer in python. Is there any help I can do regarding this?
wrking
- added a commit that references this issue
on Feb 21, 2021 Update:
With the latest update for
mypyhttp://mypy-lang.org/, it supports PEP 585 which lets us uselist[int]instead ofList[int]. We always run on the latest Python version so we will adopt the built in generic types instead of importing it from thetypingmodule.I updated the list above to reflect the directories that pass in our build GitHub Action. As contributors fix directories, please add them to the mypy tests in
.github/workflows/build.ymlso that they get tested and we do not have regressions.- added a commit that references this issue
on Apr 1, 2021 So, here's the crux of the issue: mypy does not try type-checking every single module you've imported. Instead, it only attempts to type-check modules that have explicitly opted-in to the typing ecosystem.
Modules can opt-in to the typing ecosystem via two key mechanisms:
Add type hints or stubs to their code, and include a file named py.typed within the package they distribute to PyPi (or any other package repository). The presence of this marker makes the package PEP-561-aware. The mypy docs also have more info about PEP-561-aware packages.
Alternatively, add stubs to typeshed, the repository of type hints for the standard library and select 3rd party libraries.
The aws_xray_sdk package has done neither of these things, so will be ignored by mypy.@ayushigoyal2840 The next step is to remove the
excludestatement while keeping the tests green. Once that is done, we can look into the missing imports. Once that is done, we can try adding--strictGreat work team
@ikobangs There is still work to do so please consider attacking one of the following directories:
- data_structures [mypy] Add/fix type annotations for stacks in data structures #4362
- dynamic_programming [mypy] Fix type annotations for Dynamic Programming algorithms #4332
- graphs
- maths [mypy] Add/fix type annotations for stacks in data structures #4362 [mypy] Fixed type annotations in maths #4358
- matrix
- other
- project_euler
- searches [mypy] fix directory "dynamic_programming" #4323 [mypy] Search is now fully typed with Generic types #4352
- strings
Where to start
- added a commit that references this issue
on May 13, 2021 This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
47 remaining items
- added a commit that references this issue
on Oct 26, 2021 - added a commit that references this issue
on Oct 28, 2021 - added a commit that references this issue
on Oct 28, 2021 #5608 Can anyone explain why the exclude in
mypy.inidoes not work?!?- added a commit that references this issue
on Nov 6, 2021 What remains??? https://github.com/TheAlgorithms/Python/blob/master/mypy.ini#L5
- graphs/boruvka.py
- graphs/breadth_first_search.py
- graphs/breadth_first_search_2.py
- graphs/check_cycle.py
- graphs/finding_bridges.py
- graphs/greedy_min_vertex_cover.py
- graphs/random_graph_generator.py
- matrix_operation.py [mypy] Fix
matrix_operation.py#5808 - other/least_recently_used.py
- other/lfu_cache.py
- other/lru_cache.py
- searches/simulated_annealing.py [mypy] Type annotations for searches directory #5799
- searches/ternary_search.py [mypy] Type annotations for searches directory #5799
Reacted by Sherman Hui and Rohan R BharadwajJust three left to fix...
https://github.com/TheAlgorithms/Python/blob/master/mypy.ini#L5
- other/least_recently_used.py
- other/lfu_cache.py [mypy] Annotate other/lru_cache and other/lfu_cache #5755
- other/lru_cache.py [mypy] Annotate other/lru_cache and other/lfu_cache #5755
- unpinned this issue
on Nov 16, 2021 - added a commit that references this issue
on Jul 2, 2024
Just one left to fix...
https://github.com/TheAlgorithms/Python/blob/master/mypy.ini#L5
UPDATE: Our GitHub Actions now run
mypy --ignore-missing-importsexcluding those directories that fail that test.Currently, we are not running
mypyin our regular CI tests as there are a lot of errors in the entire codebase, which needs to be fixed. This won't be a one-person job, so we are asking for help from you. I cannot paste the entire message in here as there are around 600 of them, so here's just a gist of it:Guidelines to follow:
mypyin our CI tests, the user who is submitting a pull request should run it on their local machine and ensure there are no errors in their submission.mypyin it. If possible use this template for your pull request title:Which errors to fix?
Please follow the below steps to produce all the errors in this library:
Then you need to install all the necessary requirements:
Then run either of the two commands:
mypy --ignore-missing-imports .-> To produce all the error messages for the entire codebase.mypy --ignore-missing-imports <filepath1> <filepath2> ...-> To produce error messages for the mentioned file.How to fix the errors?
Focus on one directory at a time:
Pre-requisites:
mypy: https://mypy.readthedocs.io