This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Build in type alias for paths
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.11, Python 3.10
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: arakowski
Priority: normal Keywords:

Created on 2021-06-25 20:11 by arakowski, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg396526 - (view) Author: alex rakowski (arakowski) Date: 2021-06-25 20:11
Hello,

I've noticed that when type hinting paths, it often becomes a bit verbose:

from typing import Union
import pathlib 

custom_path = Union[str, pathlib.Path]

def foobar(x:custom_path):
   ...
Writing functions which handle paths are pretty routine, I'm wondering if it is worth including something that is importable e.g.

from typing import PathLike #or similar path_obj, PathType etc. 
def foobar(x:PathLike):
 ...

Apologies if similar functionality already exists,

Alex
msg396530 - (view) Author: alex rakowski (arakowski) Date: 2021-06-25 22:49
I just noticed this issue was raised and dismissed in  PEP 519 -- Adding a file system path protocol.
History
Date User Action Args
2022-04-11 14:59:47adminsetgithub: 88675
2021-06-25 22:49:18arakowskisetstatus: open -> closed

messages: + msg396530
stage: resolved
2021-06-25 20:11:24arakowskicreate