Skip to content

Commit 01af23d

Browse files
committed
Fix typing
Stopped using native pathlib, like in cwltool
1 parent 0e616d1 commit 01af23d

File tree

4 files changed

+194
-9
lines changed

4 files changed

+194
-9
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
typing==3.5.2.2 ; python_version>="2.7"
22
avro-python3 ; python_version>="3"
33
avro==1.8.1 ; python_version<"3"
4-
pathlib2==2.1.0 ; python_version<"3.4"
4+
pathlib2==2.1.0
55
ruamel.yaml==0.12.4
66
rdflib==4.2.1
77
rdflib-jsonld==0.4.0

schema_salad/ref_resolver.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
import copy
1111
import pprint
1212
from StringIO import StringIO
13-
try:
14-
# python >3.3
15-
import pathlib # type: ignore
16-
except:
17-
import pathlib2 as pathlib # type: ignore
13+
import pathlib2
1814

1915
from . import validate
2016
from .aslist import aslist
@@ -385,8 +381,8 @@ def resolve_ref(self,
385381

386382
if not base_url:
387383
if isinstance(ref, unicode):
388-
ref = pathlib.Path(os.path.join(os.getcwd(), ref)).as_uri()
389-
base_url = pathlib.Path(os.getcwd()).as_uri() + '/'
384+
ref = pathlib2.Path(os.path.join(os.getcwd(), ref)).as_uri()
385+
base_url = pathlib2.Path(os.getcwd()).as_uri() + '/'
390386

391387
sl = SourceLine(obj, None, ValueError)
392388
# If `ref` is a dict, look for special directives.

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
'mistune >= 0.7.3, < 0.8',
3838
'typing >= 3.5.2, < 3.6',
3939
'CacheControl >= 0.11.7, < 0.12',
40-
'lockfile >= 0.9']
40+
'lockfile >= 0.9',
41+
'pathlib2 >= 2.1.0']
4142

4243
install_requires.append("avro") # TODO: remove me once cwltool is
4344
# available in Debian Stable, Ubuntu 12.04 LTS

typeshed/2.7/pathlib2.pyi

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# Stubs for pathlib2 (Python 2)
2+
#
3+
# NOTE: This dynamically typed stub was automatically generated by stubgen.
4+
5+
from typing import Any, AnyStr, Type, TypeVar, Optional, Union
6+
from collections import Sequence
7+
8+
_P = TypeVar('_P', bound='PurePath')
9+
10+
intern = ... # type: Any
11+
basestring = ... # type: Any
12+
supports_symlinks = ... # type: bool
13+
nt = ... # type: Any
14+
15+
class _Flavour:
16+
join = ... # type: Any
17+
def __init__(self) -> None: ...
18+
def parse_parts(self, parts): ...
19+
def join_parsed_parts(self, drv, root, parts, drv2, root2, parts2): ...
20+
21+
class _WindowsFlavour(_Flavour):
22+
sep = ... # type: str
23+
altsep = ... # type: str
24+
has_drv = ... # type: bool
25+
pathmod = ... # type: Any
26+
is_supported = ... # type: Any
27+
drive_letters = ... # type: Any
28+
ext_namespace_prefix = ... # type: str
29+
reserved_names = ... # type: Any
30+
def splitroot(self, part, sep: Any = ...): ...
31+
def casefold(self, s): ...
32+
def casefold_parts(self, parts): ...
33+
def resolve(self, path): ...
34+
def is_reserved(self, parts): ...
35+
def make_uri(self, path): ...
36+
def gethomedir(self, username): ...
37+
38+
class _PosixFlavour(_Flavour):
39+
sep = ... # type: str
40+
altsep = ... # type: str
41+
has_drv = ... # type: bool
42+
pathmod = ... # type: Any
43+
is_supported = ... # type: Any
44+
def splitroot(self, part, sep: Any = ...): ...
45+
def casefold(self, s): ...
46+
def casefold_parts(self, parts): ...
47+
def resolve(self, path): ...
48+
def is_reserved(self, parts): ...
49+
def make_uri(self, path): ...
50+
def gethomedir(self, username): ...
51+
52+
class _Accessor: ...
53+
54+
class _NormalAccessor(_Accessor):
55+
stat = ... # type: Any
56+
lstat = ... # type: Any
57+
open = ... # type: Any
58+
listdir = ... # type: Any
59+
chmod = ... # type: Any
60+
lchmod = ... # type: Any
61+
#def lchmod(self, pathobj, mode): ...
62+
mkdir = ... # type: Any
63+
unlink = ... # type: Any
64+
rmdir = ... # type: Any
65+
rename = ... # type: Any
66+
replace = ... # type: Any
67+
symlink = ... # type: Any
68+
#def symlink(a, b, target_is_directory): ...
69+
#@staticmethod
70+
#def symlink(a, b, target_is_directory): ...
71+
utime = ... # type: Any
72+
def readlink(self, path): ...
73+
74+
class _Selector:
75+
child_parts = ... # type: Any
76+
successor = ... # type: Any
77+
def __init__(self, child_parts) -> None: ...
78+
def select_from(self, parent_path): ...
79+
80+
class _TerminatingSelector: ...
81+
82+
class _PreciseSelector(_Selector):
83+
name = ... # type: Any
84+
def __init__(self, name, child_parts) -> None: ...
85+
86+
class _WildcardSelector(_Selector):
87+
pat = ... # type: Any
88+
def __init__(self, pat, child_parts) -> None: ...
89+
90+
class _RecursiveWildcardSelector(_Selector):
91+
def __init__(self, pat, child_parts) -> None: ...
92+
93+
class _PathParents(Sequence):
94+
def __init__(self, path) -> None: ...
95+
def __len__(self): ...
96+
def __getitem__(self, idx): ...
97+
98+
class PurePath:
99+
def __new__(cls, *args): ...
100+
def __reduce__(self): ...
101+
def as_posix(self): ...
102+
def __bytes__(self): ...
103+
def as_uri(self) -> str: ...
104+
def __eq__(self, other): ...
105+
def __ne__(self, other): ...
106+
def __hash__(self): ...
107+
def __lt__(self, other): ...
108+
def __le__(self, other): ...
109+
def __gt__(self, other): ...
110+
def __ge__(self, other): ...
111+
drive = ... # type: Any
112+
root = ... # type: Any
113+
@property
114+
def anchor(self): ...
115+
@property
116+
def name(self): ...
117+
@property
118+
def suffix(self): ...
119+
@property
120+
def suffixes(self): ...
121+
@property
122+
def stem(self): ...
123+
def with_name(self, name): ...
124+
def with_suffix(self, suffix): ...
125+
def relative_to(self, *other): ...
126+
@property
127+
def parts(self): ...
128+
def joinpath(self, *args): ...
129+
def __truediv__(self, key): ...
130+
def __rtruediv__(self, key): ...
131+
__div__ = ... # type: Any
132+
__rdiv__ = ... # type: Any
133+
@property
134+
def parent(self): ...
135+
@property
136+
def parents(self): ...
137+
def is_absolute(self): ...
138+
def is_reserved(self): ...
139+
def match(self, path_pattern): ...
140+
141+
class PurePosixPath(PurePath): ...
142+
class PureWindowsPath(PurePath): ...
143+
144+
class Path(PurePath):
145+
def __new__(cls: Type[_P], *args: Union[AnyStr, PurePath],
146+
**kwargs: Any) -> _P: ...
147+
def __enter__(self): ...
148+
def __exit__(self, t, v, tb): ...
149+
@classmethod
150+
def cwd(cls): ...
151+
@classmethod
152+
def home(cls): ...
153+
def samefile(self, other_path): ...
154+
def iterdir(self): ...
155+
def glob(self, pattern): ...
156+
def rglob(self, pattern): ...
157+
def absolute(self): ...
158+
def resolve(self): ...
159+
def stat(self): ...
160+
def owner(self): ...
161+
def group(self): ...
162+
def open(self, mode: str = ..., buffering: int = ..., encoding: Optional[Any] = ..., errors: Optional[Any] = ..., newline: Optional[Any] = ...): ...
163+
def read_bytes(self): ...
164+
def read_text(self, encoding: Optional[Any] = ..., errors: Optional[Any] = ...): ...
165+
def write_bytes(self, data): ...
166+
def write_text(self, data, encoding: Optional[Any] = ..., errors: Optional[Any] = ...): ...
167+
def touch(self, mode: int = ..., exist_ok: bool = ...): ...
168+
def mkdir(self, mode: int = ..., parents: bool = ..., exist_ok: bool = ...): ...
169+
def chmod(self, mode): ...
170+
def lchmod(self, mode): ...
171+
def unlink(self): ...
172+
def rmdir(self): ...
173+
def lstat(self): ...
174+
def rename(self, target): ...
175+
def replace(self, target): ...
176+
def symlink_to(self, target, target_is_directory: bool = ...): ...
177+
def exists(self): ...
178+
def is_dir(self): ...
179+
def is_file(self): ...
180+
def is_symlink(self): ...
181+
def is_block_device(self): ...
182+
def is_char_device(self): ...
183+
def is_fifo(self): ...
184+
def is_socket(self): ...
185+
def expanduser(self): ...
186+
187+
class PosixPath(Path, PurePosixPath): ...
188+
class WindowsPath(Path, PureWindowsPath): ...

0 commit comments

Comments
 (0)