In How do I type hint a filename in a function?, it was asked
What is a best way in Python to hint a filename, so that it's acceptable to pass anything into a function that you can open as a file?
at the time, @lxop wrote
I think what you are looking for is Structural Typing, which is not yet supported. It is proposed in PEP 544.
Given that Python 3.8+ has Structural Typing, how should we use Structural Typing hints for filenames?