PurePosixPath subclass causing Mismatch between signature.. since 1.1.373 #8525
-
Offending code: from pathlib import PurePosixPath
from pathvalidate import Platform, sanitize_filepath
class Sensor(PurePosixPath):
def __init__(self, *parts: str | PurePosixPath) -> None:
parts_ = tuple(sanitize_filepath(str(p), platform=Platform.POSIX)
for p in parts)
super(Sensor, self).__init__(*parts_) I know there's been awkwardness around |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I presume that you have manually enabled the The purpose of this check is to report situations where the According to the typeshed stubs, the class if sys.version_info >= (3, 12):
def __new__(cls, *args: StrPath, **kwargs: Unused) -> Self: ...
else:
def __new__(cls, *args: StrPath) -> Self: ... Since you're using Python 3.12, pyright will use the first of these two If you want your |
Beta Was this translation helpful? Give feedback.
I presume that you have manually enabled the
reportInconsistentConstructor
check or enabled "strict" type checking mode in your configuration. This diagnostic check is not enabled by default. If you don't want errors of this type to be reported, you can turn it back off.The purpose of this check is to report situations where the
__new__
method and__init__
method for a class are inconsistent. That is the case in your example.According to the typeshed stubs, the class
PurePosixPath
inherits a__new__
method fromPurePath
, and it is defined as: