Skip to content

Commit

Permalink
Add PurePath to PathOrFile type
Browse files Browse the repository at this point in the history
  • Loading branch information
jdidion committed Apr 9, 2019
1 parent f666952 commit 11ebb38
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions xphyle/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from io import IOBase, UnsupportedOperation
import os
from os import PathLike
from pathlib import PurePath
import stat
from typing import (
Dict,
Expand All @@ -29,7 +30,7 @@

class ModeAccess(Enum):
"""Enumeration of the access modes allowed when opening files.
See Also:
https://docs.python.org/3/library/functions.html#open
"""
Expand Down Expand Up @@ -65,7 +66,7 @@ def writable(self):

class ModeCoding(Enum):
"""Enumeration of file open modes (text or binary).
See Also:
https://docs.python.org/3/library/functions.html#open
"""
Expand All @@ -86,7 +87,7 @@ class ModeCoding(Enum):
class FileMode(object):
"""Definition of a file mode as composed of a :class:`ModeAccess` and a
:class:`ModeCoding`.
Args:
mode: Specify the mode as a string; mutually exclusive with `access`
and `coding`.
Expand Down Expand Up @@ -244,7 +245,7 @@ def os_flag(self):

class PermissionSet(object):
"""A set of :class:`Permission`s.
Args:
flags: Sequence of flags as string ('r', 'w', 'x'), int,
:class:`ModeAccess`, or :class:`Permission`.
Expand All @@ -269,7 +270,7 @@ def __init__(

def add(self, flag: PermissionArg) -> None:
"""Add a permission.
Args:
flag: Permission to add.
"""
Expand All @@ -289,7 +290,7 @@ def add(self, flag: PermissionArg) -> None:

def update(self, flags: Union["PermissionSet", Iterable[PermissionArg]]) -> None:
"""Add all flags in `flags` to this `PermissionSet`.
Args:
flags: Flags to add.
"""
Expand Down Expand Up @@ -372,7 +373,7 @@ class FileLikeInterface(IO, Iterable[AnyChar], metaclass=ABCMeta):
"""This is a marker interface for classes that implement methods (listed
below) to make them behave like python file objects. Provides a subset of
methods from typing.io.IO, plus next() and __iter__.
See Also:
https://docs.python.org/3/tutorial/inputoutput.html#methods-of-file-objects
"""
Expand Down Expand Up @@ -474,8 +475,10 @@ class PathType(Enum):
"""


PathOrFile = Union[PathLike, FileLike]
"""Either a PathLike or FileLike."""
PathOrFile = Union[PathLike, PurePath, FileLike]
"""Either a PathLike or FileLike. PurePath is only included because PathLike is
not statically assigned as a superclass of PurePath in python 3.6.
"""


Range = Tuple[int, int]
Expand Down

0 comments on commit 11ebb38

Please sign in to comment.