Skip to content

Commit ae9ddd5

Browse files
committed
Path factory requires subclass hack prior to python 3.12
1 parent c055f40 commit ae9ddd5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/test_annotated.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from pathlib import Path
2-
1+
import sys
32
import typer
43
from typer.testing import CliRunner
54
from typing_extensions import Annotated
5+
from pathlib import Path
66

77
from .utils import needs_py310
88

@@ -84,7 +84,10 @@ def test_annotated_custom_path():
8484
app = typer.Typer()
8585

8686
class CustomPath(Path):
87-
pass
87+
# Subclassing Path was not fully supported before 3.12
88+
# https://docs.python.org/3.12/whatsnew/3.12.html
89+
if sys.version_info < (3, 12):
90+
_flavour = type(Path())._flavour
8891

8992
@app.command()
9093
def custom_parser(

0 commit comments

Comments
 (0)