Skip to content

Conversation

@Akshay9715
Copy link
Contributor

Type of Changes

Type
βœ“ πŸ› Bug fix
βœ“ ✨ New feature

Description

Refs #10593

Closes #10593

  • Removed read_text from the list of deprecated functions in pylint/checkers/stdlib.py.
  • Added a new test in tests/checkers/unittest_stdlib.py:
def test_importlib_read_text_not_deprecated(self) -> None:
    """Ensure importlib.resources.read_text is NOT flagged as deprecated."""
    assign_node = astroid.extract_node("""
from importlib.resources import read_text
data = read_text("mypkg", "file.txt")
    """)
    call_node = assign_node.value  # Extract the Call node from the assignment
    with self.assertNoMessages():
        self.checker.visit_call(call_node)

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

Could you add a changelog entry? Our documentation explains how to do this :)

@codecov
Copy link

codecov bot commented Sep 29, 2025

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 95.95%. Comparing base (0871a4d) to head (cbb3a43).
⚠️ Report is 45 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10595   +/-   ##
=======================================
  Coverage   95.95%   95.95%           
=======================================
  Files         176      176           
  Lines       19476    19476           
=======================================
  Hits        18689    18689           
  Misses        787      787           
Files with missing lines Coverage Ξ”
pylint/checkers/stdlib.py 96.33% <ΓΈ> (ΓΈ)
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

This comment has been minimized.

Comment on lines 246 to 252
"importlib.resources.contents",
"importlib.resources.is_resource",
"importlib.resources.open_binary",
"importlib.resources.open_text",
"importlib.resources.path",
"importlib.resources.read_binary",
"importlib.resources.read_text",
# "importlib.resources.read_text", #un-deprecated in Python 3.13
Copy link
Member

@cdce8p cdce8p Sep 29, 2025

Choose a reason for hiding this comment

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

Please also check if any other ones from importlib.resources are falsely marked as deprecated as well. https://docs.python.org/3/library/importlib.resources.html

I believe everything except importlib.resources.contents could be removed and the deprecation of contents was moved from 3.9 to 3.11.

@Akshay9715 Akshay9715 force-pushed the fix-importlib-deprecation branch from 0b2752d to 6ea0e27 Compare September 29, 2025 11:11
"binascii.a2b_hqx",
"binascii.rlecode_hqx",
"binascii.rledecode_hqx",
"importlib.resources.contents",
Copy link
Member

Choose a reason for hiding this comment

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

This should be moved to (3, 11, 0) as the deprecation was delayed.
https://docs.python.org/3/library/importlib.resources.html#importlib.resources.contents

@github-actions

This comment has been minimized.

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code backport maintenance/4.0.x labels Sep 29, 2025
@Pierre-Sassoulas Pierre-Sassoulas added this to the 3.3.9 milestone Sep 29, 2025
@github-actions

This comment has been minimized.

@Akshay9715 Akshay9715 force-pushed the fix-importlib-deprecation branch 4 times, most recently from 135f947 to ee70de3 Compare September 30, 2025 12:28
@github-actions

This comment has been minimized.

@Akshay9715 Akshay9715 force-pushed the fix-importlib-deprecation branch 3 times, most recently from 9158d44 to ee70de3 Compare September 30, 2025 13:02
@github-actions

This comment has been minimized.

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

You'll need to make some small changes to the Changelog for the CI to agree with it. Is the error clear enough for you?

@Akshay9715
Copy link
Contributor Author

You'll need to make some small changes to the Changelog for the CI to agree with it. Is the error clear enough for you?

I’ve tried a few ways to update the Changelog to satisfy the CI, but I’m still not sure what the exact format or placement should be. Could you please guide me on how to update the Changelog so that the pre-commit CI passes?

@Akshay9715 Akshay9715 force-pushed the fix-importlib-deprecation branch 2 times, most recently from 99bddb2 to ee70de3 Compare September 30, 2025 15:47
@Akshay9715 Akshay9715 force-pushed the fix-importlib-deprecation branch from 1ad0861 to ee70de3 Compare September 30, 2025 16:01
@Akshay9715 Akshay9715 force-pushed the fix-importlib-deprecation branch from ed879b1 to b8a5155 Compare September 30, 2025 16:22
@github-actions

This comment has been minimized.

@DanielNoord DanielNoord requested a review from cdce8p September 30, 2025 18:01
Copy link
Member

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

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

Just two minor comments.

Comment on lines +1 to +3
No longer flag undeprecated functions in ``importlib.resources`` as deprecated.

Closes #10593
Copy link
Member

Choose a reason for hiding this comment

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

Would you mind moving this to 10593.false_positive. That might be an even better fit.

Sorry for the confusion.

Comment on lines 264 to 275
(3, 11, 0): {
"locale.getdefaultlocale",
"locale.resetlocale",
"re.template",
"unittest.findTestCases",
"unittest.makeSuite",
"unittest.getTestCaseNames",
"unittest.TestLoader.loadTestsFromModule",
"unittest.TestLoader.loadTestsFromTestCase",
"unittest.TestLoader.getTestCaseNames",
"unittest.TestProgram.usageExit",
"importlib.resources.contents",
Copy link
Member

Choose a reason for hiding this comment

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

I think the idea is to have these entries sorted alphabetically, though I realize that's not done consistently. Would you mind moving importlib.resources.contents to the correct place at least?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

βœ… Renamed changelog fragment to 10593.false_positive as suggested.

βœ… Moved importlib.resources.contents into alphabetical order.

@Akshay9715 Akshay9715 force-pushed the fix-importlib-deprecation branch from 55ab345 to d68a541 Compare September 30, 2025 21:07
@DanielNoord DanielNoord requested a review from cdce8p October 2, 2025 05:37
@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2025

πŸ€– According to the primer, this change has no effect on the checked open source code. πŸ€–πŸŽ‰

This comment was generated for commit cbb3a43

Copy link
Member

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

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

Thanks @Akshay9715 πŸ‘πŸ»

@cdce8p cdce8p changed the title Fix: importlib.resources.read_text not flagged as deprecated Fix flagging undeprecated importlib.resources functions Oct 2, 2025
@cdce8p cdce8p merged commit f941edd into pylint-dev:main Oct 2, 2025
44 checks passed
pylint-backport bot pushed a commit that referenced this pull request Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported False Positive 🦟 A message is emitted but nothing is wrong with the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

importlib resource API isn't deprecated

4 participants