Skip to content

Commit

Permalink
pre-commit autoupdate 2025-01-02
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss committed Jan 2, 2025
1 parent 969dfbf commit 5c63307
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- run: pip install --upgrade pip setuptools wheel
- run: pip install .[all]
- run: black --check --skip-string-normalization . || true
- run: ruff --format=github . # See pyproject.toml for configuration
- run: ruff check --output-format=github # See pyproject.toml for configuration
- run: pip install -r pex-requirements.txt -r tests/requirements.txt
- run: mypy . # See setup.cfg for configuration
- run: safety check || true # Temporary fix for https://pyup.io/v/51457/f17
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.269
rev: v0.8.5

hooks:
- id: ruff
# args: [ --fix, --exit-non-zero-on-fix ]

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.10.0
hooks:
- id: black
language_version: python3
Expand All @@ -37,12 +37,12 @@ repos:
- --skip-string-normalization

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
rev: v2.3.0
hooks:
- id: codespell # See setup.cfg for args

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.14.1
hooks:
- id: mypy
additional_dependencies:
Expand All @@ -54,6 +54,6 @@ repos:
- types-urllib3

- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.2.0
rev: v2.7.0
hooks:
- id: setup-cfg-fmt
2 changes: 1 addition & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ Release History

**Features and Improvements**

- Added support for remvoing items from simplelists as if they were collections.
- Added support for removing items from simplelists as if they were collections.
- Added ``Item.derive()`` method for deriving items.
- Added ``Item.fixer()`` method for submitting fixer tasks.
- Added ``--task-args`` to ``ia tasks`` for submitting task args to the Tasks API.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/parallel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ For example, it can be installed via `homebrew <https://brew.sh/>`_ on Mac OS::

brew install parallel

Refer to the `GNU Parallel homepage <https://www.gnu.org/software/parallel/>`_ for more details on available packaes, source code, installation, and other documentation and tutorials.
Refer to the `GNU Parallel homepage <https://www.gnu.org/software/parallel/>`_ for more details on available packages, source code, installation, and other documentation and tutorials.


Basic Usage
Expand Down
24 changes: 11 additions & 13 deletions internetarchive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,25 @@
from internetarchive.session import ArchiveSession

__all__ = [
'__version__',

# Classes.
'ArchiveSession',
'Item',
'Catalog',
'File',
'Item',
'Search',
'Catalog',

'__version__',
'configure',
'delete',
'download',
'get_files',
# API.
'get_item',
'get_files',
'modify_metadata',
'upload',
'download',
'delete',
'get_tasks',
'search_items',
'get_session',
'configure',
'get_tasks',
'get_username',
'modify_metadata',
'search_items',
'upload',
]


Expand Down
2 changes: 1 addition & 1 deletion internetarchive/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def download(
on_the_fly: bool = False,
return_responses: bool = False,
no_change_timestamp: bool = False,
timeout: int | float | tuple[int, float] | None = None,
timeout: float | tuple[int, float] | None = None,
**get_item_kwargs,
) -> list[requests.Request | requests.Response]:
r"""Download files from an item.
Expand Down
2 changes: 1 addition & 1 deletion internetarchive/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
)

__all__ = [
"ia",
"cli_utils",
"ia",
"ia_configure",
"ia_copy",
"ia_delete",
Expand Down
2 changes: 1 addition & 1 deletion internetarchive/cli/cli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_args_dict(args: list[str],
if value not in metadata[key]:
metadata[key].append(value) # type: ignore

for key in metadata:
for key in metadata: # noqa: PLC0206
# Flatten single item lists.
if len(metadata[key]) <= 1:
metadata[key] = metadata[key][0]
Expand Down
2 changes: 1 addition & 1 deletion internetarchive/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def __repr__(self):
f'size={self.size!r}, '
f'format={self.format!r})')

def download( # noqa: max-complexity=38
def download( # noqa: C901,PLR0911,PLR0912,PLR0915
self,
file_path=None,
verbose=None,
Expand Down
2 changes: 1 addition & 1 deletion internetarchive/iarequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def rm_index(key):
indexed_keys[rm_index(key)] = count

# Initialize the values for all indexed_keys.
for key in indexed_keys:
for key in indexed_keys: # noqa: PLC0206
# Increment the counter so we know how many values the final
# value in prepared_metadata should have.
indexed_keys[key] += len(source_metadata.get(key, []))
Expand Down
4 changes: 2 additions & 2 deletions internetarchive/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def download(self,
exclude_source: str | list[str] | None = None,
stdout: bool = False,
params: Mapping | None = None,
timeout: int | float | tuple[int, float] | None = None
timeout: float | tuple[int, float] | None = None
) -> list[Request | Response]:
"""Download files from an item.
Expand Down Expand Up @@ -785,7 +785,7 @@ def modify_metadata(self,
debug: bool = False,
headers: Mapping | None = None,
request_kwargs: Mapping | None = None,
timeout: int | float | None = None,
timeout: float | None = None,
refresh: bool = True) -> Request | Response:
"""Modify the metadata of an existing item on Archive.org.
Expand Down
4 changes: 2 additions & 2 deletions internetarchive/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ArchiveSession(requests.sessions.Session):
Collection(identifier='nasa', exists=True)
"""

ITEM_MEDIATYPE_TABLE = {
ITEM_MEDIATYPE_TABLE = { # noqa: RUF012
'collection': Collection,
}

Expand Down Expand Up @@ -264,7 +264,7 @@ def get_metadata(self, identifier: str, request_kwargs: MutableMapping | None =
:param identifier: Globally unique Archive.org identifier.
:returns: Metadat API response.
:returns: Metadata API response.
"""
request_kwargs = request_kwargs or {}
url = f'{self.protocol}//{self.host}/metadata/{identifier}'
Expand Down
7 changes: 3 additions & 4 deletions internetarchive/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,9 @@ def suppress_keyboard_interrupt_message() -> None:
old_excepthook = sys.excepthook

def new_hook(type, value, traceback):
if type != KeyboardInterrupt:
old_excepthook(type, value, traceback)
else:
if type is KeyboardInterrupt:
sys.exit(130)
old_excepthook(type, value, traceback)

sys.excepthook = new_hook

Expand Down Expand Up @@ -358,7 +357,7 @@ def reraise_modify(
else:
arg_list += [last_arg, append_msg]
caught_exc.args = tuple(arg_list)
raise
raise # noqa: PLE0704


def remove_none(obj):
Expand Down
13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[tool.ruff]
line-length = 102
target-version = "py37"

[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
Expand Down Expand Up @@ -66,19 +70,16 @@ ignore = [
"S318",
"S324",
]
target-version = "py37"

line-length = 102

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 33

[tool.ruff.pylint]
[tool.ruff.lint.pylint]
max-args = 24
max-branches = 33
max-statements = 124

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["E402"]
"tests/*" = ["PT017", "S101"]
"tests/cli/test_ia_list.py" = ["E741"]
Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ url = https://github.com/jjjake/internetarchive
author = Jacob M. Johnson
author_email = [email protected]
license = AGPL-3.0
license_file = LICENSE
license_files = LICENSE
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Expand All @@ -30,7 +30,7 @@ install_requires =
tqdm>=4.0.0
urllib3>=1.26.0
importlib-metadata>=3.6.0 ;python_version <= "3.10"
python_requires = >=3.7
python_requires = >=3.9
include_package_data = True
zip_safe = False

Expand Down Expand Up @@ -58,7 +58,7 @@ docs =
test =
pytest==7.1.2
responses==0.20.0
ruff==0.0.269
ruff==0.8.5
types =
tqdm-stubs>=0.2.0
types-colorama
Expand Down
13 changes: 6 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
'nasa_meta.xml',
'nasa_reviews.xml',
'nasa_itemimage.jpg',
'globe_west_540_thumb.jpg',
'__ia_thumb.jpg',
}

Expand Down Expand Up @@ -90,38 +89,38 @@ def mock_all_downloads(self, num_calls=1, body='test content', protocol='https?'
self.add(responses.GET, url, body=body)


@pytest.fixture()
@pytest.fixture
def tmpdir_ch(tmpdir):
tmpdir.chdir()
return tmpdir


@pytest.fixture()
@pytest.fixture
def nasa_mocker():
with IaRequestsMock() as mocker:
mocker.add_metadata_mock('nasa')
yield mocker


@pytest.fixture()
@pytest.fixture
def nasa_item():
session = get_session()
with IaRequestsMock() as mocker:
mocker.add_metadata_mock('nasa')
yield session.get_item('nasa')


@pytest.fixture()
@pytest.fixture
def session():
return get_session(config={'s3': {'access': 'access', 'secret': 'secret'}})


@pytest.fixture()
@pytest.fixture
def nasa_metadata():
return json.loads(load_test_data_file('metadata/nasa.json'))


# TODO: Why is this function defined twice in this file? See issue #505
@pytest.fixture() # type: ignore
@pytest.fixture # type: ignore
def nasa_item(nasa_mocker): # noqa: F811
return get_item('nasa')
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pytest==7.2.2
responses==0.23.1
ruff==0.0.269
ruff==0.8.5
2 changes: 1 addition & 1 deletion tests/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_get_item(nasa_metadata, nasa_item, session):

def test_get_file(nasa_item):
file = nasa_item.get_file('nasa_meta.xml')
assert type(file) == internetarchive.files.File
assert type(file) is internetarchive.files.File
assert file.name == 'nasa_meta.xml'


Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ envlist = py{38,39,310,311,312,313},pypy{39,310}
[testenv]
deps = -r tests/requirements.txt
# See setup.cfg for changes to default settings
commands = ruff .
commands = ruff check
pytest {posargs}

0 comments on commit 5c63307

Please sign in to comment.