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

mypy: Exclude only 20 files that are still failing #5608

Merged
merged 23 commits into from
Nov 6, 2021
Merged

Conversation

cclauss
Copy link
Member

@cclauss cclauss commented Oct 26, 2021

Let's see what is required to finish #4052

Describe your change:

  • 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}.

@cclauss
Copy link
Member Author

cclauss commented Oct 26, 2021

>>> from collections import Counter
>>> with open("mypy_output.txt") as in_file:
...     print(Counter(line.split("/")[0] for line in in_file))
...

Counter({'data_structures': 147, 'other': 56, 'searches': 45, 'matrix': 15, 'maths': 14, 'graphs': 10})

Fyi @spazm @archaengel @dylanbuchi @ErwinJunge @shermanhui

@cclauss cclauss requested a review from dhruvmanila October 26, 2021 15:15
@spazm
Copy link
Contributor

spazm commented Oct 28, 2021

>>> from collections import Counter
>>> with open("mypy_output.txt") as in_file:
...     print(Counter(line.split("/")[0] for line in in_file))
...

Counter({'data_structures': 147, 'other': 56, 'searches': 45, 'matrix': 15, 'maths': 14, 'graphs': 10})

Fyi @spazm @archaengel @dylanbuchi @ErwinJunge @shermanhui

The numbers are total number of errors per directory. The files per directory are lower.

On current master (11a15cc)

% git checkout master

% (mypy --ignore-missing-imports --install-types --non-interactive *(/) 2>&1 >/dev/null)| cut -f1 -d: | sort | uniq |  cut -f1 -d/ | sort | uniq -c
      8 data_structures
      4 graphs
      5 maths
      1 matrix
      7 other
      2 searches
      5 ven

@cclauss
Copy link
Member Author

cclauss commented Oct 29, 2021

Found 204 errors in 24 files (checked 976 source files)

30 fixed in data_structures

Counter({'data_structures': 117, 'other': 51, 'searches': 45, 'matrix': 15, 'maths': 14, 'graphs': 10})

@spazm
Copy link
Contributor

spazm commented Nov 3, 2021

other/ will be clean when the PRs in-fligh are landedt: #5647, #5648, #5653, #5656, and #5755.

The middle three were autoclosed by the bot for "multiple PR detected", so if they could be re-opened and reviewed, that'd be appreciated. [ #5648 #5653 #5656 ]

% git checkout mypy-fix-other-all

% mypy --ignore-missing-imports --install-types
Success: no issues found in 21 source files

@dylanbuchi
Copy link
Contributor

The middle three were autoclosed by the bot for "multiple PR detected", so if they could be re-opened and reviewed, that'd be appreciated. [ #5648 #5653 #5656 ]

Hey @spazm. PR's can't be reopened! You'll have to create new pull requests.

@spazm
Copy link
Contributor

spazm commented Nov 3, 2021

Hey @spazm. PR's can't be reopened! You'll have to create new pull requests.

Thanks for the info. It's a bummer, of course.

@cclauss
Copy link
Member Author

cclauss commented Nov 3, 2021

Improvements!

./graphs          || true  # Errors: 10  -> 9
./maths           || true  # Errors: 14  -> 14
./matrix          || true  # Errors: 15  -> 15
./searches        || true  # Errors: 45  -> 21
./other           || true  # Errors: 51  -> 43
./data_structures || true  # Errors: 117 -> 67

Perhaps we should start mypy --exclude individual files.

@cclauss
Copy link
Member Author

cclauss commented Nov 5, 2021

with open("mypy_output.txt") as in_file:
    filenames = sorted({line.split(':')[0] for line in in_file if ':' in line})

print(f"{len(filenames) = }")
# print("\n".join(f"                  --exclude {name}" for name in filenames))
print(f"--exclude ({'|'.join(filenames)})")

@cclauss
Copy link
Member Author

cclauss commented Nov 5, 2021

@dhruvmanila Please let me know why the mypy.ini exclude is not working.

@ErwinJunge
Copy link
Contributor

ErwinJunge commented Nov 5, 2021

@dhruvmanila Please let me know why the mypy.ini exclude is not working.

Probably due to the mv mypy.ini was_mypy.ini here: https://github.com/TheAlgorithms/Python/pull/5608/files#diff-5c3fa597431eda03ac3339ae6bf7f05e1a50d6fc7333679ec38e21b337cb6721R31

After removing that, it most likely still won't work, since you're calling mypy with specific directories. The exclude regex needs to be relative to the directory that is used as the root for discovery.

@cclauss
Copy link
Member Author

cclauss commented Nov 5, 2021

I was talking about the mypy run on line 24.

Co-authored-by: Dylan Buchi <devybuchi@gmail.com>
@cclauss cclauss requested a review from poyea November 5, 2021 13:59
@cclauss cclauss marked this pull request as ready for review November 5, 2021 14:00
@ghost ghost added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Nov 5, 2021
@cclauss cclauss changed the title DRAFT: Run a mypy reality check mypy: Exclude 20 files that are still failing Nov 5, 2021
@cclauss
Copy link
Member Author

cclauss commented Nov 5, 2021

@dylanbuchi AWESOME!! I own you a beer!!

@cclauss cclauss changed the title mypy: Exclude 20 files that are still failing mypy: Exclude only 20 files that are still failing Nov 5, 2021
Copy link
Member

@dhruvmanila dhruvmanila left a comment

Choose a reason for hiding this comment

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

A small nitpick, otherwise LGTM 👍

@@ -1,5 +1,6 @@
[mypy]
ignore_missing_imports = True
install_types = True
non_interactive = True
exclude = (data_structures/stacks/next_greater_element.py|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|maths/average_mode.py|maths/gamma_recursive.py|maths/proth_number.py|maths/series/geometric_series.py|maths/series/p_series.py|matrix_operation.py|other/fischer_yates_shuffle.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this could be done on multiline if possible for better readability. If not possible, then ignore this comment.

@ghost ghost removed the awaiting reviews This PR is ready to be reviewed label Nov 6, 2021
@cclauss cclauss merged commit 8ac86f2 into master Nov 6, 2021
@cclauss cclauss deleted the mypy-reality-check branch November 6, 2021 12:58
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.

6 participants