Skip to content

CLN: Remove unused functions/variables #43753

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 7 commits into from
Sep 28, 2021
Merged

CLN: Remove unused functions/variables #43753

merged 7 commits into from
Sep 28, 2021

Conversation

twoertwein
Copy link
Member

Found by pyright's reportUnused*.

Unused functions/variables are not directly related to typing, but pyright warns about these cases because it is asked to do unnecessary work.

@jreback jreback added the Clean label Sep 26, 2021
@jreback
Copy link
Contributor

jreback commented Sep 26, 2021

looks good, some failures

@twoertwein
Copy link
Member Author

A few of the private functions are only called by tests which caused them to fail. The only failing test now is codecov/patch for some reason.

@jreback
Copy link
Contributor

jreback commented Sep 28, 2021

can you rebase

@jreback jreback added this to the 1.4 milestone Sep 28, 2021
@twoertwein
Copy link
Member Author

@jreback rebased & green

@jreback jreback merged commit e727a56 into pandas-dev:master Sep 28, 2021
@jreback
Copy link
Contributor

jreback commented Sep 28, 2021

thanks @twoertwein did you need to turn on a pyright option to have this reported? e.g. can we have it always run? (or is it expensive)

@twoertwein
Copy link
Member Author

I didn't turn them one because we have false-positives. We "exclude" pandas/tests - if we were to "ignore" pandas/tests, we probaly wouldn't have these false-positives anymore but pyright might be 30-50s slower if it has to work through the mostly un-typed tests.

The four options from pyright are:

  • reportUnusedClass: is only "offended" in one file (pickle compat) where a private class is refernced using only a string. We could disable reportUnusedClass for this file using with a comment at the top of the file.
  • reportUnusedFunction: needs a discussion whether these private functions should either be moved (often they are used only one time, but defiend in a different file) or made "public" (at least remove the leading "_")
  • reportUnusedImport: could probably be enabled if __all__ or redundant import were used (main "offenders" are the api.py files)
  • reportUnusedVariable: needs consensus to start unused variables with _ (flake8-bugbear has the same rules but it is not enabled because it is "controversial").

gasparitiago pushed a commit to gasparitiago/pandas that referenced this pull request Oct 9, 2021
@twoertwein twoertwein deleted the unused branch June 8, 2022 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants