Skip to content

Commit

Permalink
Regenerate the parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Sep 8, 2024
1 parent 14191d3 commit 8058c74
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 69 deletions.
14 changes: 6 additions & 8 deletions cwl_utils/parser/cwl_v1_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ def __init__(
self.fetcher = copyfrom.fetcher
else:
import requests
from cachecontrol.caches import FileCache
from cachecontrol.caches import SeparateBodyFileCache
from cachecontrol.wrapper import CacheControl

root = pathlib.Path(os.environ.get("HOME", tempfile.gettempdir()))
session = CacheControl(
requests.Session(),
cache=FileCache(root / ".cache" / "salad"),
cache=SeparateBodyFileCache(root / ".cache" / "salad"),
)
self.fetcher: Fetcher = DefaultFetcher({}, session)

Expand Down Expand Up @@ -293,9 +293,9 @@ def parse_errors(error_message: str) -> Tuple[str, str, str]:
types.add(individual_vals[-1].strip("."))
else:
types.add(individual_vals[1].replace(",", ""))
types = set(val for val in types if val != "NoneType")
types = {val for val in types if val != "NoneType"}
if "str" in types:
types = set(convert_typing(val) for val in types if "'" not in val)
types = {convert_typing(val) for val in types if "'" not in val}
to_print = ""
for val in types:
if "'" in val:
Expand Down Expand Up @@ -463,9 +463,7 @@ def load(
lc: Optional[List[Any]] = None,
) -> Any:
if not isinstance(doc, self.tp):
raise ValidationException(
"Expected a {} but got {}".format(self.tp, doc.__class__.__name__)
)
raise ValidationException(f"Expected a {self.tp} but got {doc.__class__.__name__}")
return doc

def __repr__(self) -> str:
Expand Down Expand Up @@ -495,7 +493,7 @@ def load(
for i in range(0, len(doc)):
try:
lf = load_field(
doc[i], _UnionLoader(([self, self.items])), baseuri, loadingOptions, lc=lc
doc[i], _UnionLoader([self, self.items]), baseuri, loadingOptions, lc=lc
)
flatten = loadingOptions.container != "@list"
if flatten and isinstance(lf, MutableSequence):
Expand Down
14 changes: 6 additions & 8 deletions cwl_utils/parser/cwl_v1_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ def __init__(
self.fetcher = copyfrom.fetcher
else:
import requests
from cachecontrol.caches import FileCache
from cachecontrol.caches import SeparateBodyFileCache
from cachecontrol.wrapper import CacheControl

root = pathlib.Path(os.environ.get("HOME", tempfile.gettempdir()))
session = CacheControl(
requests.Session(),
cache=FileCache(root / ".cache" / "salad"),
cache=SeparateBodyFileCache(root / ".cache" / "salad"),
)
self.fetcher: Fetcher = DefaultFetcher({}, session)

Expand Down Expand Up @@ -293,9 +293,9 @@ def parse_errors(error_message: str) -> Tuple[str, str, str]:
types.add(individual_vals[-1].strip("."))
else:
types.add(individual_vals[1].replace(",", ""))
types = set(val for val in types if val != "NoneType")
types = {val for val in types if val != "NoneType"}
if "str" in types:
types = set(convert_typing(val) for val in types if "'" not in val)
types = {convert_typing(val) for val in types if "'" not in val}
to_print = ""
for val in types:
if "'" in val:
Expand Down Expand Up @@ -463,9 +463,7 @@ def load(
lc: Optional[List[Any]] = None,
) -> Any:
if not isinstance(doc, self.tp):
raise ValidationException(
"Expected a {} but got {}".format(self.tp, doc.__class__.__name__)
)
raise ValidationException(f"Expected a {self.tp} but got {doc.__class__.__name__}")
return doc

def __repr__(self) -> str:
Expand Down Expand Up @@ -495,7 +493,7 @@ def load(
for i in range(0, len(doc)):
try:
lf = load_field(
doc[i], _UnionLoader(([self, self.items])), baseuri, loadingOptions, lc=lc
doc[i], _UnionLoader([self, self.items]), baseuri, loadingOptions, lc=lc
)
flatten = loadingOptions.container != "@list"
if flatten and isinstance(lf, MutableSequence):
Expand Down
14 changes: 6 additions & 8 deletions cwl_utils/parser/cwl_v1_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ def __init__(
self.fetcher = copyfrom.fetcher
else:
import requests
from cachecontrol.caches import FileCache
from cachecontrol.caches import SeparateBodyFileCache
from cachecontrol.wrapper import CacheControl

root = pathlib.Path(os.environ.get("HOME", tempfile.gettempdir()))
session = CacheControl(
requests.Session(),
cache=FileCache(root / ".cache" / "salad"),
cache=SeparateBodyFileCache(root / ".cache" / "salad"),
)
self.fetcher: Fetcher = DefaultFetcher({}, session)

Expand Down Expand Up @@ -293,9 +293,9 @@ def parse_errors(error_message: str) -> Tuple[str, str, str]:
types.add(individual_vals[-1].strip("."))
else:
types.add(individual_vals[1].replace(",", ""))
types = set(val for val in types if val != "NoneType")
types = {val for val in types if val != "NoneType"}
if "str" in types:
types = set(convert_typing(val) for val in types if "'" not in val)
types = {convert_typing(val) for val in types if "'" not in val}
to_print = ""
for val in types:
if "'" in val:
Expand Down Expand Up @@ -463,9 +463,7 @@ def load(
lc: Optional[List[Any]] = None,
) -> Any:
if not isinstance(doc, self.tp):
raise ValidationException(
"Expected a {} but got {}".format(self.tp, doc.__class__.__name__)
)
raise ValidationException(f"Expected a {self.tp} but got {doc.__class__.__name__}")
return doc

def __repr__(self) -> str:
Expand Down Expand Up @@ -495,7 +493,7 @@ def load(
for i in range(0, len(doc)):
try:
lf = load_field(
doc[i], _UnionLoader(([self, self.items])), baseuri, loadingOptions, lc=lc
doc[i], _UnionLoader([self, self.items]), baseuri, loadingOptions, lc=lc
)
flatten = loadingOptions.container != "@list"
if flatten and isinstance(lf, MutableSequence):
Expand Down
11 changes: 9 additions & 2 deletions mypy-stubs/cachecontrol/cache.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
from datetime import datetime
from typing import IO

class BaseCache:
def get(self, key: str) -> str | None: ...
def set(self, key: str, value: str) -> None: ...
def get(self, key: str) -> bytes | None: ...
def set(self, key: str, value: bytes, expires: int | datetime | None = None) -> None: ...
def delete(self, key: str) -> None: ...
def close(self) -> None: ...

class SeparateBodyBaseCache(BaseCache):
def set_body(self, key: str, body: bytes) -> None: ...
def get_body(self, key: str) -> IO[bytes] | None: ...
14 changes: 4 additions & 10 deletions mypy-stubs/cachecontrol/caches/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# Stubs for cachecontrol.caches (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from cachecontrol.caches.file_cache import (
SeparateBodyFileCache as SeparateBodyFileCache,
)

from typing import Any

from .file_cache import FileCache as FileCache

# from .redis_cache import RedisCache as RedisCache

notice = ... # type: Any
__all__ = ["SeparateBodyFileCache"]
38 changes: 21 additions & 17 deletions mypy-stubs/cachecontrol/caches/file_cache.pyi
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
from os import PathLike
from typing import ContextManager
from datetime import datetime
from pathlib import Path
from typing import IO, ContextManager

from ..cache import BaseCache as BaseCache
from ..controller import CacheController as CacheController
from cachecontrol.cache import SeparateBodyBaseCache
from filelock import BaseFileLock

class _LockClass:
path: str

_lock_class = ContextManager[_LockClass]

class FileCache(BaseCache):
directory: str | PathLike[str]
class _FileCacheMixin:
directory: str
forever: bool
filemode: str
dirmode: str
lock_class: _lock_class
filemode: int
dirmode: int
lock_class: _lock_class | None = None
def __init__(
self,
directory: str | PathLike[str],
forever: bool = ...,
filemode: int = ...,
dirmode: int = ...,
use_dir_lock: bool | None = ...,
lock_class: _lock_class | None = ...,
directory: str | Path,
forever: bool = False,
filemode: int = 384,
dirmode: int = 448,
lock_class: type[BaseFileLock] | None = None,
) -> None: ...
@staticmethod
def encode(x: str) -> str: ...
def get(self, key: str) -> None | str: ...
def set(self, key: str, value: str) -> None: ...
def get(self, key: str) -> bytes | None: ...
def set(self, key: str, value: bytes, expires: int | datetime | None = None) -> None: ...

class SeparateBodyFileCache(_FileCacheMixin, SeparateBodyBaseCache):
def get_body(self, key: str) -> IO[bytes] | None: ...
def set_body(self, key: str, body: bytes) -> None: ...
def delete(self, key: str) -> None: ...
19 changes: 10 additions & 9 deletions mypy-stubs/cachecontrol/controller.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from typing import Collection

from _typeshed import Incomplete

logger: Incomplete
URI: Incomplete
from .cache import BaseCache

class CacheController:
cache: Incomplete
cache_etags: Incomplete
cache: BaseCache
cache_etags: bool
serializer: Incomplete
cacheable_status_codes: Incomplete
cacheable_status_codes: Collection[int] | None = None
def __init__(
self,
cache: Incomplete | None = ...,
cache_etags: bool = ...,
serializer: Incomplete | None = ...,
status_codes: Incomplete | None = ...,
cache: BaseCache | None = None,
cache_etags: bool = True,
serializer: Incomplete | None = None,
status_codes: Collection[int] | None = None,
) -> None: ...
19 changes: 12 additions & 7 deletions mypy-stubs/cachecontrol/wrapper.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
from typing import Collection, Type

from _typeshed import Incomplete
from requests import Session

from .cache import BaseCache
from .controller import CacheController

def CacheControl(
sess: Session,
cache: Incomplete | None = ...,
cache_etags: bool = ...,
serializer: Incomplete | None = ...,
heuristic: Incomplete | None = ...,
controller_class: Incomplete | None = ...,
adapter_class: Incomplete | None = ...,
cacheable_methods: Incomplete | None = ...,
cache: BaseCache | None = None,
cache_etags: bool = True,
serializer: Incomplete | None = None,
heuristic: Incomplete | None = None,
controller_class: Type[CacheController] | None = None,
adapter_class: Incomplete | None = None,
cacheable_methods: Collection[str] | None = None,
) -> Session: ...

0 comments on commit 8058c74

Please sign in to comment.