Skip to content

Commit

Permalink
Fix typing
Browse files Browse the repository at this point in the history
Stopped using native pathlib, like in cwltool
  • Loading branch information
psafont committed Dec 21, 2016
1 parent 0e616d1 commit 01af23d
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 9 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
typing==3.5.2.2 ; python_version>="2.7"
avro-python3 ; python_version>="3"
avro==1.8.1 ; python_version<"3"
pathlib2==2.1.0 ; python_version<"3.4"
pathlib2==2.1.0
ruamel.yaml==0.12.4
rdflib==4.2.1
rdflib-jsonld==0.4.0
Expand Down
10 changes: 3 additions & 7 deletions schema_salad/ref_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
import copy
import pprint
from StringIO import StringIO
try:
# python >3.3
import pathlib # type: ignore
except:
import pathlib2 as pathlib # type: ignore
import pathlib2

from . import validate
from .aslist import aslist
Expand Down Expand Up @@ -385,8 +381,8 @@ def resolve_ref(self,

if not base_url:
if isinstance(ref, unicode):
ref = pathlib.Path(os.path.join(os.getcwd(), ref)).as_uri()
base_url = pathlib.Path(os.getcwd()).as_uri() + '/'
ref = pathlib2.Path(os.path.join(os.getcwd(), ref)).as_uri()
base_url = pathlib2.Path(os.getcwd()).as_uri() + '/'

sl = SourceLine(obj, None, ValueError)
# If `ref` is a dict, look for special directives.
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
'mistune >= 0.7.3, < 0.8',
'typing >= 3.5.2, < 3.6',
'CacheControl >= 0.11.7, < 0.12',
'lockfile >= 0.9']
'lockfile >= 0.9',
'pathlib2 >= 2.1.0']

install_requires.append("avro") # TODO: remove me once cwltool is
# available in Debian Stable, Ubuntu 12.04 LTS
Expand Down
188 changes: 188 additions & 0 deletions typeshed/2.7/pathlib2.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
# Stubs for pathlib2 (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Any, AnyStr, Type, TypeVar, Optional, Union
from collections import Sequence

_P = TypeVar('_P', bound='PurePath')

intern = ... # type: Any
basestring = ... # type: Any
supports_symlinks = ... # type: bool
nt = ... # type: Any

class _Flavour:
join = ... # type: Any
def __init__(self) -> None: ...
def parse_parts(self, parts): ...
def join_parsed_parts(self, drv, root, parts, drv2, root2, parts2): ...

class _WindowsFlavour(_Flavour):
sep = ... # type: str
altsep = ... # type: str
has_drv = ... # type: bool
pathmod = ... # type: Any
is_supported = ... # type: Any
drive_letters = ... # type: Any
ext_namespace_prefix = ... # type: str
reserved_names = ... # type: Any
def splitroot(self, part, sep: Any = ...): ...
def casefold(self, s): ...
def casefold_parts(self, parts): ...
def resolve(self, path): ...
def is_reserved(self, parts): ...
def make_uri(self, path): ...
def gethomedir(self, username): ...

class _PosixFlavour(_Flavour):
sep = ... # type: str
altsep = ... # type: str
has_drv = ... # type: bool
pathmod = ... # type: Any
is_supported = ... # type: Any
def splitroot(self, part, sep: Any = ...): ...
def casefold(self, s): ...
def casefold_parts(self, parts): ...
def resolve(self, path): ...
def is_reserved(self, parts): ...
def make_uri(self, path): ...
def gethomedir(self, username): ...

class _Accessor: ...

class _NormalAccessor(_Accessor):
stat = ... # type: Any
lstat = ... # type: Any
open = ... # type: Any
listdir = ... # type: Any
chmod = ... # type: Any
lchmod = ... # type: Any
#def lchmod(self, pathobj, mode): ...
mkdir = ... # type: Any
unlink = ... # type: Any
rmdir = ... # type: Any
rename = ... # type: Any
replace = ... # type: Any
symlink = ... # type: Any
#def symlink(a, b, target_is_directory): ...
#@staticmethod
#def symlink(a, b, target_is_directory): ...
utime = ... # type: Any
def readlink(self, path): ...

class _Selector:
child_parts = ... # type: Any
successor = ... # type: Any
def __init__(self, child_parts) -> None: ...
def select_from(self, parent_path): ...

class _TerminatingSelector: ...

class _PreciseSelector(_Selector):
name = ... # type: Any
def __init__(self, name, child_parts) -> None: ...

class _WildcardSelector(_Selector):
pat = ... # type: Any
def __init__(self, pat, child_parts) -> None: ...

class _RecursiveWildcardSelector(_Selector):
def __init__(self, pat, child_parts) -> None: ...

class _PathParents(Sequence):
def __init__(self, path) -> None: ...
def __len__(self): ...
def __getitem__(self, idx): ...

class PurePath:
def __new__(cls, *args): ...
def __reduce__(self): ...
def as_posix(self): ...
def __bytes__(self): ...
def as_uri(self) -> str: ...
def __eq__(self, other): ...
def __ne__(self, other): ...
def __hash__(self): ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
drive = ... # type: Any
root = ... # type: Any
@property
def anchor(self): ...
@property
def name(self): ...
@property
def suffix(self): ...
@property
def suffixes(self): ...
@property
def stem(self): ...
def with_name(self, name): ...
def with_suffix(self, suffix): ...
def relative_to(self, *other): ...
@property
def parts(self): ...
def joinpath(self, *args): ...
def __truediv__(self, key): ...
def __rtruediv__(self, key): ...
__div__ = ... # type: Any
__rdiv__ = ... # type: Any
@property
def parent(self): ...
@property
def parents(self): ...
def is_absolute(self): ...
def is_reserved(self): ...
def match(self, path_pattern): ...

class PurePosixPath(PurePath): ...
class PureWindowsPath(PurePath): ...

class Path(PurePath):
def __new__(cls: Type[_P], *args: Union[AnyStr, PurePath],
**kwargs: Any) -> _P: ...
def __enter__(self): ...
def __exit__(self, t, v, tb): ...
@classmethod
def cwd(cls): ...
@classmethod
def home(cls): ...
def samefile(self, other_path): ...
def iterdir(self): ...
def glob(self, pattern): ...
def rglob(self, pattern): ...
def absolute(self): ...
def resolve(self): ...
def stat(self): ...
def owner(self): ...
def group(self): ...
def open(self, mode: str = ..., buffering: int = ..., encoding: Optional[Any] = ..., errors: Optional[Any] = ..., newline: Optional[Any] = ...): ...
def read_bytes(self): ...
def read_text(self, encoding: Optional[Any] = ..., errors: Optional[Any] = ...): ...
def write_bytes(self, data): ...
def write_text(self, data, encoding: Optional[Any] = ..., errors: Optional[Any] = ...): ...
def touch(self, mode: int = ..., exist_ok: bool = ...): ...
def mkdir(self, mode: int = ..., parents: bool = ..., exist_ok: bool = ...): ...
def chmod(self, mode): ...
def lchmod(self, mode): ...
def unlink(self): ...
def rmdir(self): ...
def lstat(self): ...
def rename(self, target): ...
def replace(self, target): ...
def symlink_to(self, target, target_is_directory: bool = ...): ...
def exists(self): ...
def is_dir(self): ...
def is_file(self): ...
def is_symlink(self): ...
def is_block_device(self): ...
def is_char_device(self): ...
def is_fifo(self): ...
def is_socket(self): ...
def expanduser(self): ...

class PosixPath(Path, PurePosixPath): ...
class WindowsPath(Path, PureWindowsPath): ...

0 comments on commit 01af23d

Please sign in to comment.