Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/whatsnew/fragments/11763.false_negative
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Fix a false negative for ``deprecated-class`` where classes deprecated in an older
Python version were not reported when a newer Python version deprecated more classes
of the same module, for example ``typing.ByteString`` on Python 3.14.

Closes #11763
4 changes: 3 additions & 1 deletion pylint/checkers/stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,9 @@ def __init__(self, linter: PyLinter) -> None:
self._deprecated_arguments.update(args_list)
for since_vers, class_list in DEPRECATED_CLASSES.items():
if since_vers <= sys.version_info:
self._deprecated_classes.update(class_list)
# A module can be listed for several versions: merge, don't replace
for module, classes in class_list.items():
self._deprecated_classes.setdefault(module, set()).update(classes)
for since_vers, decorator_list in DEPRECATED_DECORATORS.items():
if since_vers <= sys.version_info:
self._deprecated_decorators.update(decorator_list)
Expand Down
17 changes: 17 additions & 0 deletions tests/functional/d/deprecated/deprecated_class_py314.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Test deprecated classes of modules that are listed for several Python versions.

The classes deprecated in an older version must still be reported when a newer
version adds more deprecated classes to the same module.
"""
# pylint: disable=unused-import,import-error,no-name-in-module,abstract-class-instantiated

import asyncio
import typing
from ast import Num # [deprecated-class]
from importlib.abc import Finder # [deprecated-class]
from typing import ByteString, Text # [deprecated-class, deprecated-class]
from webbrowser import MacOSX # [deprecated-class]

typing.Hashable() # [deprecated-class]
asyncio.SafeChildWatcher() # [deprecated-class]
asyncio.DefaultEventLoopPolicy() # [deprecated-class]
2 changes: 2 additions & 0 deletions tests/functional/d/deprecated/deprecated_class_py314.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[testoptions]
min_pyver=3.14
8 changes: 8 additions & 0 deletions tests/functional/d/deprecated/deprecated_class_py314.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
deprecated-class:10:0:10:19::Using deprecated class Num of module ast:UNDEFINED
deprecated-class:11:0:11:32::Using deprecated class Finder of module importlib.abc:UNDEFINED
deprecated-class:12:0:12:35::Using deprecated class ByteString of module typing:UNDEFINED
deprecated-class:12:0:12:35::Using deprecated class Text of module typing:UNDEFINED
deprecated-class:13:0:13:29::Using deprecated class MacOSX of module webbrowser:UNDEFINED
deprecated-class:15:0:15:17::Using deprecated class Hashable of module typing:UNDEFINED
deprecated-class:16:0:16:26::Using deprecated class SafeChildWatcher of module asyncio:UNDEFINED
deprecated-class:17:0:17:32::Using deprecated class DefaultEventLoopPolicy of module asyncio:UNDEFINED