Skip to content

Commit

Permalink
Update to 2024 black style (#396)
Browse files Browse the repository at this point in the history
* Update to 2024 black style

* Skip black for Python 3.7

* Use official pytest-cases again

* Remove superfluous parentheses from @fixture decorator

* Revert "Remove superfluous parentheses from @fixture decorator"

This reverts commit aacbb5d.

* Pin below pytest 8

---------

Co-authored-by: Jay Qi <[email protected]>
  • Loading branch information
jayqi and jayqi committed Jan 28, 2024
1 parent 9936a10 commit 991704a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 31 deletions.
34 changes: 14 additions & 20 deletions cloudpathlib/cloudpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ def decorator(cls: Type[CloudPathT]) -> Type[CloudPathT]:

class CloudPathMeta(abc.ABCMeta):
@overload
def __call__(cls: Type[T], cloud_path: CloudPathT, *args: Any, **kwargs: Any) -> CloudPathT:
...
def __call__(
cls: Type[T], cloud_path: CloudPathT, *args: Any, **kwargs: Any
) -> CloudPathT: ...

@overload
def __call__(
cls: Type[T], cloud_path: Union[str, "CloudPath"], *args: Any, **kwargs: Any
) -> T:
...
) -> T: ...

def __call__(
cls: Type[T], cloud_path: Union[str, CloudPathT], *args: Any, **kwargs: Any
Expand Down Expand Up @@ -274,13 +274,13 @@ def _no_prefix_no_drive(self) -> str:

@overload
@classmethod
def is_valid_cloudpath(cls, path: "CloudPath", raise_on_error: bool = ...) -> TypeGuard[Self]:
...
def is_valid_cloudpath(
cls, path: "CloudPath", raise_on_error: bool = ...
) -> TypeGuard[Self]: ...

@overload
@classmethod
def is_valid_cloudpath(cls, path: str, raise_on_error: bool = ...) -> bool:
...
def is_valid_cloudpath(cls, path: str, raise_on_error: bool = ...) -> bool: ...

@classmethod
def is_valid_cloudpath(
Expand Down Expand Up @@ -940,24 +940,21 @@ def copy(
self,
destination: Self,
force_overwrite_to_cloud: bool = False,
) -> Self:
...
) -> Self: ...

@overload
def copy(
self,
destination: Path,
force_overwrite_to_cloud: bool = False,
) -> Path:
...
) -> Path: ...

@overload
def copy(
self,
destination: str,
force_overwrite_to_cloud: bool = False,
) -> Union[Path, "CloudPath"]:
...
) -> Union[Path, "CloudPath"]: ...

def copy(self, destination, force_overwrite_to_cloud=False):
"""Copy self to destination folder of file, if self is a file."""
Expand Down Expand Up @@ -1007,26 +1004,23 @@ def copytree(
destination: Self,
force_overwrite_to_cloud: bool = False,
ignore: Optional[Callable[[str, Iterable[str]], Container[str]]] = None,
) -> Self:
...
) -> Self: ...

@overload
def copytree(
self,
destination: Path,
force_overwrite_to_cloud: bool = False,
ignore: Optional[Callable[[str, Iterable[str]], Container[str]]] = None,
) -> Path:
...
) -> Path: ...

@overload
def copytree(
self,
destination: str,
force_overwrite_to_cloud: bool = False,
ignore: Optional[Callable[[str, Iterable[str]], Container[str]]] = None,
) -> Union[Path, "CloudPath"]:
...
) -> Union[Path, "CloudPath"]: ...

def copytree(self, destination, force_overwrite_to_cloud=False, ignore=None):
"""Copy self to a directory, if self is a directory."""
Expand Down
7 changes: 3 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-e .[all]

black[jupyter]
black[jupyter]>=24.1.0;python_version>='3.8'
build
flake8
ipytest
Expand All @@ -19,9 +19,8 @@ pandas
pillow
psutil
pydantic
pytest
# pytest-cases
git+https://github.com/jayqi/python-pytest-cases@packaging-version
pytest<8
pytest-cases>=3.7.0
pytest-cov
pytest-xdist
python-dotenv
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
ignore = E731,E266,E501,C901,W503,E203
ignore = E731,E266,E501,C901,W503,E203,E704
max-line-length = 99
exclude =
.git,
Expand Down
6 changes: 3 additions & 3 deletions tests/mock_clients/mock_azureblob.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ def upload_blob(self, data, overwrite, content_settings=None):
path.write_bytes(data)

if content_settings is not None:
self.service_client.metadata_cache[
self.root / self.key
] = content_settings.content_type
self.service_client.metadata_cache[self.root / self.key] = (
content_settings.content_type
)


class MockStorageStreamDownloader:
Expand Down
8 changes: 5 additions & 3 deletions tests/mock_clients/mock_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,11 @@ def paginate(self, Bucket=None, Prefix="", Delimiter=None):
files = [
{
"Key": str(_.relative_to(self.root).as_posix()),
"Size": 123
if not _.relative_to(self.root).exists()
else _.relative_to(self.root).stat().st_size,
"Size": (
123
if not _.relative_to(self.root).exists()
else _.relative_to(self.root).stat().st_size
),
}
for _ in page
if _.is_file()
Expand Down

0 comments on commit 991704a

Please sign in to comment.