Skip to content

Commit 8058c74

Browse files
committed
Regenerate the parsers
1 parent 14191d3 commit 8058c74

File tree

8 files changed

+74
-69
lines changed

8 files changed

+74
-69
lines changed

cwl_utils/parser/cwl_v1_0.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ def __init__(
139139
self.fetcher = copyfrom.fetcher
140140
else:
141141
import requests
142-
from cachecontrol.caches import FileCache
142+
from cachecontrol.caches import SeparateBodyFileCache
143143
from cachecontrol.wrapper import CacheControl
144144

145145
root = pathlib.Path(os.environ.get("HOME", tempfile.gettempdir()))
146146
session = CacheControl(
147147
requests.Session(),
148-
cache=FileCache(root / ".cache" / "salad"),
148+
cache=SeparateBodyFileCache(root / ".cache" / "salad"),
149149
)
150150
self.fetcher: Fetcher = DefaultFetcher({}, session)
151151

@@ -293,9 +293,9 @@ def parse_errors(error_message: str) -> Tuple[str, str, str]:
293293
types.add(individual_vals[-1].strip("."))
294294
else:
295295
types.add(individual_vals[1].replace(",", ""))
296-
types = set(val for val in types if val != "NoneType")
296+
types = {val for val in types if val != "NoneType"}
297297
if "str" in types:
298-
types = set(convert_typing(val) for val in types if "'" not in val)
298+
types = {convert_typing(val) for val in types if "'" not in val}
299299
to_print = ""
300300
for val in types:
301301
if "'" in val:
@@ -463,9 +463,7 @@ def load(
463463
lc: Optional[List[Any]] = None,
464464
) -> Any:
465465
if not isinstance(doc, self.tp):
466-
raise ValidationException(
467-
"Expected a {} but got {}".format(self.tp, doc.__class__.__name__)
468-
)
466+
raise ValidationException(f"Expected a {self.tp} but got {doc.__class__.__name__}")
469467
return doc
470468

471469
def __repr__(self) -> str:
@@ -495,7 +493,7 @@ def load(
495493
for i in range(0, len(doc)):
496494
try:
497495
lf = load_field(
498-
doc[i], _UnionLoader(([self, self.items])), baseuri, loadingOptions, lc=lc
496+
doc[i], _UnionLoader([self, self.items]), baseuri, loadingOptions, lc=lc
499497
)
500498
flatten = loadingOptions.container != "@list"
501499
if flatten and isinstance(lf, MutableSequence):

cwl_utils/parser/cwl_v1_1.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ def __init__(
139139
self.fetcher = copyfrom.fetcher
140140
else:
141141
import requests
142-
from cachecontrol.caches import FileCache
142+
from cachecontrol.caches import SeparateBodyFileCache
143143
from cachecontrol.wrapper import CacheControl
144144

145145
root = pathlib.Path(os.environ.get("HOME", tempfile.gettempdir()))
146146
session = CacheControl(
147147
requests.Session(),
148-
cache=FileCache(root / ".cache" / "salad"),
148+
cache=SeparateBodyFileCache(root / ".cache" / "salad"),
149149
)
150150
self.fetcher: Fetcher = DefaultFetcher({}, session)
151151

@@ -293,9 +293,9 @@ def parse_errors(error_message: str) -> Tuple[str, str, str]:
293293
types.add(individual_vals[-1].strip("."))
294294
else:
295295
types.add(individual_vals[1].replace(",", ""))
296-
types = set(val for val in types if val != "NoneType")
296+
types = {val for val in types if val != "NoneType"}
297297
if "str" in types:
298-
types = set(convert_typing(val) for val in types if "'" not in val)
298+
types = {convert_typing(val) for val in types if "'" not in val}
299299
to_print = ""
300300
for val in types:
301301
if "'" in val:
@@ -463,9 +463,7 @@ def load(
463463
lc: Optional[List[Any]] = None,
464464
) -> Any:
465465
if not isinstance(doc, self.tp):
466-
raise ValidationException(
467-
"Expected a {} but got {}".format(self.tp, doc.__class__.__name__)
468-
)
466+
raise ValidationException(f"Expected a {self.tp} but got {doc.__class__.__name__}")
469467
return doc
470468

471469
def __repr__(self) -> str:
@@ -495,7 +493,7 @@ def load(
495493
for i in range(0, len(doc)):
496494
try:
497495
lf = load_field(
498-
doc[i], _UnionLoader(([self, self.items])), baseuri, loadingOptions, lc=lc
496+
doc[i], _UnionLoader([self, self.items]), baseuri, loadingOptions, lc=lc
499497
)
500498
flatten = loadingOptions.container != "@list"
501499
if flatten and isinstance(lf, MutableSequence):

cwl_utils/parser/cwl_v1_2.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ def __init__(
139139
self.fetcher = copyfrom.fetcher
140140
else:
141141
import requests
142-
from cachecontrol.caches import FileCache
142+
from cachecontrol.caches import SeparateBodyFileCache
143143
from cachecontrol.wrapper import CacheControl
144144

145145
root = pathlib.Path(os.environ.get("HOME", tempfile.gettempdir()))
146146
session = CacheControl(
147147
requests.Session(),
148-
cache=FileCache(root / ".cache" / "salad"),
148+
cache=SeparateBodyFileCache(root / ".cache" / "salad"),
149149
)
150150
self.fetcher: Fetcher = DefaultFetcher({}, session)
151151

@@ -293,9 +293,9 @@ def parse_errors(error_message: str) -> Tuple[str, str, str]:
293293
types.add(individual_vals[-1].strip("."))
294294
else:
295295
types.add(individual_vals[1].replace(",", ""))
296-
types = set(val for val in types if val != "NoneType")
296+
types = {val for val in types if val != "NoneType"}
297297
if "str" in types:
298-
types = set(convert_typing(val) for val in types if "'" not in val)
298+
types = {convert_typing(val) for val in types if "'" not in val}
299299
to_print = ""
300300
for val in types:
301301
if "'" in val:
@@ -463,9 +463,7 @@ def load(
463463
lc: Optional[List[Any]] = None,
464464
) -> Any:
465465
if not isinstance(doc, self.tp):
466-
raise ValidationException(
467-
"Expected a {} but got {}".format(self.tp, doc.__class__.__name__)
468-
)
466+
raise ValidationException(f"Expected a {self.tp} but got {doc.__class__.__name__}")
469467
return doc
470468

471469
def __repr__(self) -> str:
@@ -495,7 +493,7 @@ def load(
495493
for i in range(0, len(doc)):
496494
try:
497495
lf = load_field(
498-
doc[i], _UnionLoader(([self, self.items])), baseuri, loadingOptions, lc=lc
496+
doc[i], _UnionLoader([self, self.items]), baseuri, loadingOptions, lc=lc
499497
)
500498
flatten = loadingOptions.container != "@list"
501499
if flatten and isinstance(lf, MutableSequence):

mypy-stubs/cachecontrol/cache.pyi

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
from datetime import datetime
2+
from typing import IO
3+
14
class BaseCache:
2-
def get(self, key: str) -> str | None: ...
3-
def set(self, key: str, value: str) -> None: ...
5+
def get(self, key: str) -> bytes | None: ...
6+
def set(self, key: str, value: bytes, expires: int | datetime | None = None) -> None: ...
47
def delete(self, key: str) -> None: ...
58
def close(self) -> None: ...
9+
10+
class SeparateBodyBaseCache(BaseCache):
11+
def set_body(self, key: str, body: bytes) -> None: ...
12+
def get_body(self, key: str) -> IO[bytes] | None: ...
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
# Stubs for cachecontrol.caches (Python 2)
2-
#
3-
# NOTE: This dynamically typed stub was automatically generated by stubgen.
1+
from cachecontrol.caches.file_cache import (
2+
SeparateBodyFileCache as SeparateBodyFileCache,
3+
)
44

5-
from typing import Any
6-
7-
from .file_cache import FileCache as FileCache
8-
9-
# from .redis_cache import RedisCache as RedisCache
10-
11-
notice = ... # type: Any
5+
__all__ = ["SeparateBodyFileCache"]
Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
1-
from os import PathLike
2-
from typing import ContextManager
1+
from datetime import datetime
2+
from pathlib import Path
3+
from typing import IO, ContextManager
34

4-
from ..cache import BaseCache as BaseCache
5-
from ..controller import CacheController as CacheController
5+
from cachecontrol.cache import SeparateBodyBaseCache
6+
from filelock import BaseFileLock
67

78
class _LockClass:
89
path: str
910

1011
_lock_class = ContextManager[_LockClass]
1112

12-
class FileCache(BaseCache):
13-
directory: str | PathLike[str]
13+
class _FileCacheMixin:
14+
directory: str
1415
forever: bool
15-
filemode: str
16-
dirmode: str
17-
lock_class: _lock_class
16+
filemode: int
17+
dirmode: int
18+
lock_class: _lock_class | None = None
1819
def __init__(
1920
self,
20-
directory: str | PathLike[str],
21-
forever: bool = ...,
22-
filemode: int = ...,
23-
dirmode: int = ...,
24-
use_dir_lock: bool | None = ...,
25-
lock_class: _lock_class | None = ...,
21+
directory: str | Path,
22+
forever: bool = False,
23+
filemode: int = 384,
24+
dirmode: int = 448,
25+
lock_class: type[BaseFileLock] | None = None,
2626
) -> None: ...
2727
@staticmethod
2828
def encode(x: str) -> str: ...
29-
def get(self, key: str) -> None | str: ...
30-
def set(self, key: str, value: str) -> None: ...
29+
def get(self, key: str) -> bytes | None: ...
30+
def set(self, key: str, value: bytes, expires: int | datetime | None = None) -> None: ...
31+
32+
class SeparateBodyFileCache(_FileCacheMixin, SeparateBodyBaseCache):
33+
def get_body(self, key: str) -> IO[bytes] | None: ...
34+
def set_body(self, key: str, body: bytes) -> None: ...
3135
def delete(self, key: str) -> None: ...
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
from typing import Collection
2+
13
from _typeshed import Incomplete
24

3-
logger: Incomplete
4-
URI: Incomplete
5+
from .cache import BaseCache
56

67
class CacheController:
7-
cache: Incomplete
8-
cache_etags: Incomplete
8+
cache: BaseCache
9+
cache_etags: bool
910
serializer: Incomplete
10-
cacheable_status_codes: Incomplete
11+
cacheable_status_codes: Collection[int] | None = None
1112
def __init__(
1213
self,
13-
cache: Incomplete | None = ...,
14-
cache_etags: bool = ...,
15-
serializer: Incomplete | None = ...,
16-
status_codes: Incomplete | None = ...,
14+
cache: BaseCache | None = None,
15+
cache_etags: bool = True,
16+
serializer: Incomplete | None = None,
17+
status_codes: Collection[int] | None = None,
1718
) -> None: ...

mypy-stubs/cachecontrol/wrapper.pyi

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
from typing import Collection, Type
2+
13
from _typeshed import Incomplete
24
from requests import Session
35

6+
from .cache import BaseCache
7+
from .controller import CacheController
8+
49
def CacheControl(
510
sess: Session,
6-
cache: Incomplete | None = ...,
7-
cache_etags: bool = ...,
8-
serializer: Incomplete | None = ...,
9-
heuristic: Incomplete | None = ...,
10-
controller_class: Incomplete | None = ...,
11-
adapter_class: Incomplete | None = ...,
12-
cacheable_methods: Incomplete | None = ...,
11+
cache: BaseCache | None = None,
12+
cache_etags: bool = True,
13+
serializer: Incomplete | None = None,
14+
heuristic: Incomplete | None = None,
15+
controller_class: Type[CacheController] | None = None,
16+
adapter_class: Incomplete | None = None,
17+
cacheable_methods: Collection[str] | None = None,
1318
) -> Session: ...

0 commit comments

Comments
 (0)