Skip to content

Commit

Permalink
Update for cloudpathlib 0.16 (#68)
Browse files Browse the repository at this point in the history
* Update for cloudpathlib 0.16

* Unskip python 3.12 remote tests
* Remove cloudpathlib warnings
* Address `tar.extractall` `filter` deprecation warning for python 3.12+
* Update mypy

* Remove unused imports
  • Loading branch information
adrianeboyd authored Oct 16, 2023
1 parent f8d12f3 commit bae505b
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12.0-rc.2"]
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
include:
- os: ubuntu-20.04
python_version: "3.6"
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ confection>=0.0.4,<0.2.0
wasabi>=0.9.1,<1.2.0
srsly>=2.4.3,<3.0.0
typer>=0.3.0,<0.10.0
cloudpathlib>=0.7.0,<0.16.0
cloudpathlib>=0.7.0,<0.17.0
smart-open>=5.2.1,<7.0.0
# Third party dependencies
requests>=2.13.0,<3.0.0
Expand All @@ -13,7 +13,7 @@ packaging>=20.0
# Development dependencies
black==22.3.0
pytest>=5.2.0,!=7.1.0
mypy>=0.990,<1.1.0; platform_machine != "aarch64" and python_version >= "3.7"
mypy>=1.5.0,<1.7.0; python_version >= "3.8"
types-requests
types-setuptools>=57.0.0
ruff>=0.0.259; python_version > "3.6"
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ install_requires =
wasabi>=0.9.1,<1.2.0
srsly>=2.4.3,<3.0.0
typer>=0.3.0,<0.10.0
cloudpathlib>=0.7.0,<0.16.0
cloudpathlib>=0.7.0,<0.17.0
smart-open>=5.2.1,<7.0.0
requests>=2.13.0,<3.0.0
pydantic>=1.7.4,!=1.8,!=1.8.1,<3.0.0
Expand Down
6 changes: 5 additions & 1 deletion weasel/cli/remote_storage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import hashlib
import os
import site
import sys
import tarfile
import urllib.parse
from pathlib import Path
Expand Down Expand Up @@ -97,7 +98,10 @@ def safe_extract(tar, path):
member_path = os.path.join(path, member.name)
if not is_within_directory(path, member_path):
raise ValueError(Errors.E201)
tar.extractall(path)
if sys.version_info >= (3, 12):
tar.extractall(path, filter="data")
else:
tar.extractall(path)

safe_extract(tar_file, self.root)
return url
Expand Down
7 changes: 0 additions & 7 deletions weasel/tests/cli/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys
import time

import pytest
Expand Down Expand Up @@ -114,9 +113,6 @@ def test_is_subpath_of(parent, child, expected):
assert is_subpath_of(parent, child) == expected


@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="Python 3.12+ not supported for remotes"
)
def test_local_remote_storage():
with make_tempdir() as d:
filename = "a.txt"
Expand Down Expand Up @@ -162,9 +158,6 @@ def test_local_remote_storage():
assert file_.read() == content


@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="Python 3.12+ not supported for remotes"
)
def test_local_remote_storage_pull_missing():
# pulling from a non-existent remote pulls nothing gracefully
with make_tempdir() as d:
Expand Down
4 changes: 0 additions & 4 deletions weasel/tests/cli/test_cli_app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
from pathlib import Path
from typing import Any, Dict

Expand Down Expand Up @@ -164,9 +163,6 @@ def test_project_clone(tmp_path: Path, options_string: str):
assert (out / "README.md").is_file()


@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="Python 3.12+ not supported for remotes"
)
def test_project_push_pull(tmp_path: Path, project_dir: Path):
proj = dict(SAMPLE_PROJECT)
remote = "xyz"
Expand Down
4 changes: 0 additions & 4 deletions weasel/tests/cli/test_remote.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
from pathlib import Path

import pytest
Expand All @@ -10,9 +9,6 @@

runner = CliRunner()

if sys.version_info >= (3, 12):
pytest.skip("Python 3.12+ not supported for remotes", allow_module_level=True)


@pytest.fixture
def project_dir(tmp_path_factory: pytest.TempPathFactory):
Expand Down
9 changes: 1 addition & 8 deletions weasel/util/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,7 @@ def ensure_pathy(path):
"""Temporary helper to prevent importing cloudpathlib globally (which was
originally added due to a slow and annoying Google Cloud warning with
Pathy)"""
try:
from cloudpathlib import AnyPath # noqa: F811
except ImportError as e:
import sys

if sys.version_info >= (3, 12):
warnings.warn(Warnings.W802)
raise e
from cloudpathlib import AnyPath # noqa: F811

return AnyPath(path)

Expand Down

0 comments on commit bae505b

Please sign in to comment.