GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-120417: Fix "imported but unused" linter warnings by vstinner · Pull Request #120461 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jun 13, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Add __all__ to the following modules: collections.abc, importlib.machinery, importlib.util and xml.sax.

Add also "# noqa: F401" in subprocess and xml.sax on two lines.

  • Issue: Remove unused imports from the stdlib #120417

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
pythongh-120417: Fix "imported but unused" linter warnings
56cbf55
Add __all__ to the following modules: collections.abc,
importlib.machinery, importlib.util and xml.sax.

Add also "# noqa: F401" in subprocess and xml.sax on two lines.
@vstinner vstinner added the skip news label Jun 13, 2024
@vstinner
vstinner requested review from brettcannon, ericsnowcurrently, gpshead, ncoghlan, rhettinger and warsaw as code owners June 13, 2024 17:14
@bedevere-app bedevere-app Bot mentioned this pull request Jun 13, 2024
Remove unused imports from the stdlib #120417
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Jun 13, 2024
@vstinner vstinner mentioned this pull request Jun 13, 2024
gh-120417: Add more #noqa to used imports in the stdlib #120454
Closed
@rhettinger
rhettinger removed their request for review June 13, 2024 17:21
gpshead
gpshead approved these changes Jun 13, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Jun 13, 2024
hugovk
hugovk approved these changes Jun 13, 2024
View reviewed changes

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

My only nitpick is to put them in alphabetical order, to make it easier to find an import when scanning the list.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner

vstinner commented Jun 13, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

My only nitpick is to put them in alphabetical order, to make it easier to find an import when scanning the list.

Are you talking about __all__? I put them in definition order. I have no preference.

hugovk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka reviewed Jun 14, 2024
View reviewed changes
Comment thread Lib/collections/abc.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/importlib/util.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
Sort __all__; remove collections.abc.__all__; remove private names
a0176c6
@vstinner

vstinner commented Jun 14, 2024

Copy link
Copy Markdown
Member Author

I updated the PR:

  • Remove private names (_ prefix) in __all__
  • Sort __all__
  • Remove collections.abc.__all__: use # noqa instead
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka reviewed Jun 14, 2024
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It is easy to get __all__ de-synchronized with the module content. I think that all changed modules need tests for __all__. See existing tests that use support.check__all__.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ericsnowcurrently and AlexWaygood reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@vstinner
Add tests
ef483e7
@vstinner

vstinner commented Jun 14, 2024

Copy link
Copy Markdown
Member Author

I think that all changed modules need tests for all. See existing tests that use support.check__all__.

Ok, I added tests.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka approved these changes Jun 14, 2024
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. I tested that __all__ includes all non-underscored names except module names.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@vstinner
vstinner merged commit 05df063 into python:main Jun 14, 2024
@vstinner
vstinner deleted the import_qa3 branch June 14, 2024 18:39
@bedevere-app bedevere-app Bot removed the awaiting merge label Jun 14, 2024
mrahtz pushed a commit to mrahtz/cpython that referenced this pull request Jun 30, 2024
@vstinner @mrahtz
pythongh-120417: Fix "imported but unused" linter warnings (python#12…
4c42c6d
…0461)

Add __all__ to the following modules:
importlib.machinery, importlib.util and xml.sax.

Add also "# noqa: F401" in collections.abc,
subprocess and xml.sax.

* Sort __all__; remove collections.abc.__all__; remove private names

* Add tests
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
@vstinner @estyxx
pythongh-120417: Fix "imported but unused" linter warnings (python#12…
5800a9e
…0461)

Add __all__ to the following modules:
importlib.machinery, importlib.util and xml.sax.

Add also "# noqa: F401" in collections.abc,
subprocess and xml.sax.

* Sort __all__; remove collections.abc.__all__; remove private names

* Add tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gpshead gpshead gpshead approved these changes
@hugovk hugovk hugovk approved these changes
@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@brettcannon brettcannon Awaiting requested review from brettcannon brettcannon is a code owner
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@ncoghlan ncoghlan Awaiting requested review from ncoghlan ncoghlan is a code owner
@warsaw warsaw Awaiting requested review from warsaw warsaw is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@vstinner @gpshead @ericsnowcurrently @hugovk @serhiy-storchaka
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.