From ee6b34b10978e6047663931fefd28ef463c71566 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Tue, 13 Aug 2024 12:21:22 +0200 Subject: [PATCH 1/4] fnmatch: support pathlib --- stdlib/fnmatch.pyi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stdlib/fnmatch.pyi b/stdlib/fnmatch.pyi index 7051c999c430..b0e4453e1eaa 100644 --- a/stdlib/fnmatch.pyi +++ b/stdlib/fnmatch.pyi @@ -1,9 +1,10 @@ from collections.abc import Iterable -from typing import AnyStr +from pathlib import Path +from typing import AnyStr, Union __all__ = ["filter", "fnmatch", "fnmatchcase", "translate"] -def fnmatch(name: AnyStr, pat: AnyStr) -> bool: ... -def fnmatchcase(name: AnyStr, pat: AnyStr) -> bool: ... -def filter(names: Iterable[AnyStr], pat: AnyStr) -> list[AnyStr]: ... +def fnmatch(name: Union[AnyStr, Path], pat: AnyStr) -> bool: ... +def fnmatchcase(name: Union[AnyStr, Path], pat: AnyStr) -> bool: ... +def filter(names: Iterable[Union[AnyStr, Path]], pat: AnyStr) -> list[AnyStr]: ... def translate(pat: str) -> str: ... From e8a28e474c4a4e95080a513099b6dd2deef9fc3b Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Tue, 13 Aug 2024 15:31:01 +0200 Subject: [PATCH 2/4] Use builtin GenericPath stub Co-authored-by: Alex Waygood --- stdlib/fnmatch.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/fnmatch.pyi b/stdlib/fnmatch.pyi index b0e4453e1eaa..3473a41cc386 100644 --- a/stdlib/fnmatch.pyi +++ b/stdlib/fnmatch.pyi @@ -4,7 +4,7 @@ from typing import AnyStr, Union __all__ = ["filter", "fnmatch", "fnmatchcase", "translate"] -def fnmatch(name: Union[AnyStr, Path], pat: AnyStr) -> bool: ... -def fnmatchcase(name: Union[AnyStr, Path], pat: AnyStr) -> bool: ... -def filter(names: Iterable[Union[AnyStr, Path]], pat: AnyStr) -> list[AnyStr]: ... +def fnmatch(name: GenericPath[AnyStr], pat: AnyStr) -> bool: ... +def fnmatchcase(name: GenericPath[AnyStr], pat: AnyStr) -> bool: ... +def filter(names: Iterable[GenericPath[AnyStr]], pat: AnyStr) -> list[AnyStr]: ... def translate(pat: str) -> str: ... From f0c032ea61e288e4f017818ffdef86cc4eb193ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 13:32:43 +0000 Subject: [PATCH 3/4] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/fnmatch.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stdlib/fnmatch.pyi b/stdlib/fnmatch.pyi index 3473a41cc386..45a87381e185 100644 --- a/stdlib/fnmatch.pyi +++ b/stdlib/fnmatch.pyi @@ -1,6 +1,5 @@ from collections.abc import Iterable -from pathlib import Path -from typing import AnyStr, Union +from typing import AnyStr __all__ = ["filter", "fnmatch", "fnmatchcase", "translate"] From d5b4b4c49037a81a908befb8f441aadd2a48ff96 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Tue, 13 Aug 2024 16:04:55 +0200 Subject: [PATCH 4/4] Don't forget import --- stdlib/fnmatch.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/fnmatch.pyi b/stdlib/fnmatch.pyi index 45a87381e185..abb3234dc65d 100644 --- a/stdlib/fnmatch.pyi +++ b/stdlib/fnmatch.pyi @@ -1,3 +1,4 @@ +from _typeshed import GenericPath from collections.abc import Iterable from typing import AnyStr