You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@dhruvmanila Is mypy running properly in our Travis CI runs? I believe that I made a mistake in #2464 which mypy is complaining about but it only seems to be raising issues in the maths subdirectory. Are we doing something wrong here?
I see the problem.
As mentioned in #2463 (comment), mypy ignores all the directories which don't contain the __init__.py file, and as the maths subdirectory contains the __init__.py file, mypy is only complaining about the errors in that specific directory. I will put the highlights here:
Updated metrics
There's already an open issue about it (Why do we need __init__.py files?): python/mypy#6385
Here's Guido van Rossum explaining what is going on: python/mypy#6385 (comment)
Out of 124 directories only 62 contains the __init__.py file and most of them are the project_euler/.. directories.
It's checking only for 116 files while there are around 736 files with extension py with around 124 directories according to:
$ fd -t f -e py --full-path Python/ | wc -l # find files with extension py and count the lines 736
$ fd -t d --full-path Python/ | wc -l # find directories and count the lines 124
By running a simple bash script, I found that __init__.py exists only in these directories, but mypy will stop recursing into the subdirectories if it doesn't find __init__.py file in the parent directory. What I mean is it looks for Python files in ./Python/maths/ but not in ./Python/data_structures/stacks/ as there is no init file in data_structures directory.
__init__.py exists in ./Python/data_structures/hashing/number_theory/
__init__.py exists in ./Python/data_structures/linked_list/
__init__.py exists in ./Python/data_structures/stacks/
__init__.py exists in ./Python/digital_image_processing/
__init__.py exists in ./Python/digital_image_processing/dithering/
__init__.py exists in ./Python/digital_image_processing/edge_detection/
__init__.py exists in ./Python/digital_image_processing/filters/
__init__.py exists in ./Python/digital_image_processing/resize/
__init__.py exists in ./Python/digital_image_processing/rotation/
__init__.py exists in ./Python/maths/
__init__.py exists in ./Python/project_euler/problem_01/
...
And all the subdirectories of project_euler/..
For now, the only solution is to add the __init__.py files in all the directories and subdirectories (which can be easily done using a simple bash script).
OK. Can you please submit a PR that ONLY adds all these __init__.py files (that way we can revert the commit in the future if mypy comes up with a more rational approach). After we land that PR, we can create another PR that fixes the mypy issues and removes the || true. Thanks for your research on this topic.
Activity
dhruvmanila commentedon Sep 28, 2020
Let me take a look at it and I'll get back to you.
dhruvmanila commentedon Sep 28, 2020
I see the problem.
As mentioned in #2463 (comment),
mypyignores all the directories which don't contain the__init__.pyfile, and as themathssubdirectory contains the__init__.pyfile,mypyis only complaining about the errors in that specific directory. I will put the highlights here:Updated metrics
By running a simple
bashscript, I found that__init__.pyexists only in these directories, butmypywill stop recursing into the subdirectories if it doesn't find__init__.pyfile in the parent directory. What I mean is it looks for Python files in./Python/maths/but not in./Python/data_structures/stacks/as there is noinitfile indata_structuresdirectory.For now, the only solution is to add the
__init__.pyfiles in all the directories and subdirectories (which can be easily done using a simplebashscript).dhruvmanila commentedon Sep 28, 2020
I added the file in their respective directories and found this after running
mypy --ignore-missing-imports Python/Found 507 errors in 129 files (checked 736 source files) 😱
cclauss commentedon Sep 28, 2020
OK. Can you please submit a PR that ONLY adds all these
__init__.pyfiles (that way we can revert the commit in the future if mypy comes up with a more rational approach). After we land that PR, we can create another PR that fixes the mypy issues and removes the|| true. Thanks for your research on this topic.