Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 2024 black style #396

Merged
merged 6 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Copy link
Member Author

@jayqi jayqi Jan 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a floor here so that dev environments are consistent.

black has dropped Python 3.7. People shouldn't be doing dev in a 3.7 environment anyways, so skipping black here seems like a good workaround for us to keep the 3.7 tests going for a while.

We should probably consider dropping 3.7 support soon though.

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
Copy link
Member Author

@jayqi jayqi Jan 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest v8.0.0 literally just released hours ago, and there's some arcane looking error that is probably a pytest-cases incompatibility.

I opened an issue: smarie/python-pytest-cases#330

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
Copy link
Member Author

@jayqi jayqi Jan 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted here, flake8's E704 conflicts with the new concise dummy implementation style

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
Loading