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-102515: Remove unused imports in the `Lib/` directory by AlexWaygood · Pull Request #102516 · python/cpython

Conversation

@AlexWaygood

@AlexWaygood AlexWaygood commented Mar 7, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Identified using the pycln tool; manually reviewed by me.

  • Fixes Unused imports in the Lib/ directory #102515

Sorry, something went wrong.

Uh oh!

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

All reactions
@AlexWaygood
Remove unused imports in the Lib/ directory
9a4a4ac
@AlexWaygood
AlexWaygood requested review from a team, 1st1, FFY00, asvetlov, ericvsmith, ethanfurman, gvanrossum, iritkatriel, kumaraditya303, lysnikolaou, pablogsal, rhettinger, tiran and vsajip as code owners March 7, 2023 22:01
@bedevere-bot bedevere-bot mentioned this pull request Mar 7, 2023
Unused imports in the Lib/ directory #102515
Closed
@bedevere-bot bedevere-bot added the awaiting core review label Mar 7, 2023
@AlexWaygood AlexWaygood added skip news stdlib Standard Library Python modules in the Lib/ directory labels Mar 7, 2023
FFY00
FFY00 approved these changes Mar 7, 2023
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Mar 7, 2023
gvanrossum
gvanrossum reviewed Mar 7, 2023
View reviewed changes
Comment thread Lib/concurrent/futures/process.py Resolved

Uh oh!

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

Comment thread Lib/multiprocessing/queues.py Resolved

Uh oh!

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

Comment thread Lib/test/test_asyncio/test_ssl.py Resolved

Uh oh!

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

Comment thread Lib/test/test_peg_generator/test_c_parser.py Resolved

Uh oh!

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

@AlexWaygood
Revert dubious changes to Lib/concurrent/ and Lib/multiprocessing/
a21b7e8
@hugovk

hugovk commented Mar 7, 2023

Copy link
Copy Markdown
Member

Maybe worth commenting some of the less-obvious, required imports for next time?

All reactions

Sorry, something went wrong.

Uh oh!

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

@terryjreedy

terryjreedy commented Mar 7, 2023

Copy link
Copy Markdown
Member

Of the 34 files with 'extra' imports, 28 are in test. If the tests pass, we may assume that the deletions are really unused. I am checking the deletions in regular code and already found an error.

gvanrossum reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

@AlexWaygood
Make the import in concurrent/futures/process.py more explicit
b3488e8
@terryjreedy

terryjreedy commented Mar 7, 2023

Copy link
Copy Markdown
Member

Guido refuted my comment about not checking tests, and found the issue with multliprocessing.connection. I consider that to be a bug in pycln.

All reactions

Sorry, something went wrong.

Uh oh!

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

@terryjreedy terryjreedy closed this Mar 7, 2023
@terryjreedy terryjreedy reopened this Mar 7, 2023
@AlexWaygood
Revert b3488e8, add a comment instead
4269138
@AlexWaygood

AlexWaygood commented Mar 7, 2023

Copy link
Copy Markdown
Member Author

I consider that to be a bug in pycln.

It's an imperfect tool, and the stdlib is possibly the worst kind of code to judge it on. I've had good experiences with using the tool on other projects, but if you simply run pycln Lib --all in the CPython repo, it removes 290 imports from 150 files. Most of these are false positives.

All reactions

Sorry, something went wrong.

Uh oh!

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

gvanrossum
gvanrossum reviewed Mar 7, 2023
View reviewed changes
Comment thread Lib/multiprocessing/queues.py Resolved

Uh oh!

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

@rhettinger
rhettinger removed their request for review March 8, 2023 02:49
gvanrossum
gvanrossum approved these changes Mar 8, 2023
View reviewed changes
kumaraditya303
kumaraditya303 approved these changes Mar 8, 2023
View reviewed changes
@pablogsal
pablogsal merged commit 401d7a7 into python:main Mar 8, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Mar 8, 2023
@AlexWaygood
AlexWaygood deleted the unused-imports branch March 8, 2023 11:47
@AlexWaygood

AlexWaygood commented Mar 8, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

Thanks @gvanrossum, @terryjreedy and @kumaraditya303 for the careful reviews! Much appreciated.

All reactions

Sorry, something went wrong.

Uh oh!

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

carljm added a commit to carljm/cpython that referenced this pull request Mar 8, 2023
@carljm
Merge branch 'main' into inlinecomp2
06db319
* main:
  pythongh-102304: Consolidate Direct Usage of _Py_RefTotal (pythongh-102514)
  pythongh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Objects/) (python#102218)
  pythongh-102507 Remove invisible pagebreak characters (python#102531)
  pythongh-102515: Remove unused imports in the `Lib/` directory (python#102516)
  Remove or update bitbucket links (pythonGH-101963)
  pythongh-101100: Fix sphinx warnings in `zipapp` and `zipfile` modules (python#102526)
  pythonGH-102397: Fix segfault from race condition in signal handling (python#102399)
  Fix style in argparse.rst (python#101733)
  Post 3.12.0a6
  fix typo in async generator code field name `ag_code` (python#102448)
  Python 3.12.0a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gvanrossum gvanrossum gvanrossum approved these changes
@FFY00 FFY00 FFY00 approved these changes
@kumaraditya303 kumaraditya303 kumaraditya303 approved these changes
@ethanfurman ethanfurman Awaiting requested review from ethanfurman ethanfurman is a code owner
@ericvsmith ericvsmith Awaiting requested review from ericvsmith ericvsmith is a code owner
@pablogsal pablogsal Awaiting requested review from pablogsal pablogsal is a code owner
@lysnikolaou lysnikolaou Awaiting requested review from lysnikolaou lysnikolaou is a code owner
@vsajip vsajip Awaiting requested review from vsajip vsajip is a code owner
@tiran tiran Awaiting requested review from tiran
@iritkatriel iritkatriel Awaiting requested review from iritkatriel
@1st1 1st1 Awaiting requested review from 1st1 1st1 is a code owner
@asvetlov asvetlov Awaiting requested review from asvetlov asvetlov is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

skip news stdlib Standard Library Python modules in the Lib/ directory

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Unused imports in the Lib/ directory

Uh oh!

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

8 participants

@AlexWaygood @hugovk @terryjreedy @gvanrossum @FFY00 @kumaraditya303 @pablogsal @bedevere-bot
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 01402503 — 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.