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: Add #noqa to load_tests() in tests by vstinner · Pull Request #120626 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jun 17, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Ignore linter "imported but unused" warnings in tests when the linter doesn't understand why the import is important.

  • 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: Add #noqa to load_tests() in tests
59c1e46
@vstinner vstinner added the skip news label Jun 17, 2024
@vstinner
vstinner requested review from a team, 1st1, ambv, asvetlov, berkerpeksag, encukou, ericsnowcurrently, erlend-aasland, gvanrossum, hauntsaninja, kumaraditya303, lysnikolaou, pablogsal and willingc as code owners June 17, 2024 11:23
@bedevere-app bedevere-app Bot mentioned this pull request Jun 17, 2024
Remove unused imports from the stdlib #120417
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Jun 17, 2024
@encukou

encukou commented Jun 17, 2024

Copy link
Copy Markdown
Member

Could you add/link an explanation about what noqa: F401 means and how to maintain it?

In my projects, I've avoided these warning by adding public names to __all__, rather than with a cryptic comment.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Jun 17, 2024

Copy link
Copy Markdown
Member Author

Could you add/link an explanation about what noqa: F401 means and how to maintain it?

It's a "standard" linter command to ignore "imported but unused" warning on the current line.

It was discussed at #120421.

All reactions

Sorry, something went wrong.

Uh oh!

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

@serhiy-storchaka

serhiy-storchaka commented Jun 17, 2024

Copy link
Copy Markdown
Member

Could you add an exception for load_tests in a global configuration file?

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Jun 17, 2024

Copy link
Copy Markdown
Member Author

@serhiy-storchaka:

Could you add an exception for load_tests in a global configuration file?

I have no idea on how to do that.

@AlexWaygood: Is it something supported by Ruff by example?

All reactions

Sorry, something went wrong.

Uh oh!

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

@AlexWaygood

AlexWaygood commented Jun 17, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

@AlexWaygood: Is it something supported by Ruff by example?

we support ignoring certain errors for filenames that match certain patterns. But I don't think we support ignoring F401 for specific symbols, no. It might be a reasonable feature request.

All reactions

Sorry, something went wrong.

Uh oh!

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

@serhiy-storchaka

serhiy-storchaka commented Jun 17, 2024

Copy link
Copy Markdown
Member

Can it be ignored for Lib/test/*/**/__main__.py? All these files are the same.

AlexWaygood 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.

@AlexWaygood

AlexWaygood commented Jun 17, 2024

Copy link
Copy Markdown
Member

Yes, in Ruff you can do that via the CLI using --config='lint.per-file-ignores = {"Lib/test/*/**/__main__.py" = ["F401"]}'. Or in a pyproject.toml configuration file, you can do this:

[tool.ruff.lint.per-file-ignores]
"Lib/test/*/**/__main__.py" = ["F401"]

Or this in a ruff.toml configuration file:

[lint.per-file-ignores]
"Lib/test/*/**/__main__.py" = ["F401"]
All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Jun 17, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

Can it be ignored for Lib/test/*/**/__main__.py? All these files are the same.

It means that other unused imports can no longer be catched.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Jun 19, 2024

Copy link
Copy Markdown
Member Author

In total, ruff check|grep F401 returns 173 lines. These load_tests are not the worst, so I prefer to close this PR for now.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner closed this Jun 19, 2024
@vstinner
vstinner deleted the noqa_main branch June 19, 2024 14:08
@vstinner vstinner mentioned this pull request Mar 13, 2025
Remove unused imports - March 2025 Edition #131152
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@encukou encukou Awaiting requested review from encukou encukou is a code owner
@hauntsaninja hauntsaninja Awaiting requested review from hauntsaninja hauntsaninja is a code owner
@berkerpeksag berkerpeksag Awaiting requested review from berkerpeksag
@erlend-aasland erlend-aasland Awaiting requested review from erlend-aasland erlend-aasland 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
@ambv ambv Awaiting requested review from ambv ambv is a code owner
@1st1 1st1 Awaiting requested review from 1st1 1st1 is a code owner
@asvetlov asvetlov Awaiting requested review from asvetlov asvetlov is a code owner
@gvanrossum gvanrossum Awaiting requested review from gvanrossum
@kumaraditya303 kumaraditya303 Awaiting requested review from kumaraditya303 kumaraditya303 is a code owner
@willingc willingc Awaiting requested review from willingc willingc is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

awaiting core review 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.

4 participants

@vstinner @encukou @serhiy-storchaka @AlexWaygood
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.