Skip to content

Commit c3d7a7c

Browse files
committed
Fix: remove importlib.resources.read_text from deprecated list and add test
1 parent 0871a4d commit c3d7a7c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pylint/checkers/stdlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
"importlib.resources.open_text",
250250
"importlib.resources.path",
251251
"importlib.resources.read_binary",
252-
"importlib.resources.read_text",
252+
# "importlib.resources.read_text", #un-deprecated in Python 3.13
253253
},
254254
(3, 10, 0): {
255255
"_sqlite3.enable_shared_cache",

tests/checkers/unittest_stdlib.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,16 @@ def infer_func(
6868
)
6969
with self.assertNoMessages():
7070
self.checker.visit_call(node)
71+
72+
def test_importlib_read_text_not_deprecated(self) -> None:
73+
"""Ensure importlib.resources.read_text is NOT flagged as deprecated."""
74+
assign_node = astroid.extract_node("""
75+
from importlib.resources import read_text
76+
data = read_text("mypkg", "file.txt")
77+
""")
78+
call_node = assign_node.value # The value of the Assign node is the Call node
79+
with self.assertNoMessages():
80+
self.checker.visit_call(call_node)
81+
82+
83+

0 commit comments

Comments
 (0)