From 1bd1625c3662c1c1a68ba28612d4b6799c445bc9 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 2 Aug 2022 09:15:46 +0300 Subject: [PATCH] importlib: `SimplePath`: `__div__` -> `__truediv__` on 3.10 (#8451) Co-authored-by: Alex Waygood --- stdlib/importlib/metadata/_meta.pyi | 9 ++++----- tests/stubtest_allowlists/py310.txt | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/stdlib/importlib/metadata/_meta.pyi b/stdlib/importlib/metadata/_meta.pyi index 6a7cd858c..e3504fe40 100644 --- a/stdlib/importlib/metadata/_meta.pyi +++ b/stdlib/importlib/metadata/_meta.pyi @@ -1,4 +1,3 @@ -import sys from collections.abc import Iterator from typing import Any, Protocol, TypeVar @@ -17,7 +16,7 @@ class SimplePath(Protocol): def joinpath(self) -> SimplePath: ... def parent(self) -> SimplePath: ... def read_text(self) -> str: ... - if sys.version_info >= (3, 11): - def __truediv__(self) -> SimplePath: ... - else: - def __div__(self) -> SimplePath: ... + # There was a bug in `SimplePath` definition in cpython, see #8451 + # Strictly speaking `__div__` was defined in 3.10, not __truediv__, + # but it should have always been `__truediv__`. + def __truediv__(self) -> SimplePath: ... diff --git a/tests/stubtest_allowlists/py310.txt b/tests/stubtest_allowlists/py310.txt index 94a2a810a..726ae7b34 100644 --- a/tests/stubtest_allowlists/py310.txt +++ b/tests/stubtest_allowlists/py310.txt @@ -17,6 +17,8 @@ fractions.Fraction.__new__ # overload is too complicated for stubtest to resolv gettext.install gettext.translation hmac.new # Stub is a white lie; see comments in the stub +importlib.metadata._meta.SimplePath.__div__ # See comments +importlib.metadata._meta.SimplePath.__truediv__ # See comments ipaddress.IPv4Interface.hostmask ipaddress.IPv6Interface.hostmask ipaddress._BaseNetwork.broadcast_address