diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml
index 10877bce..a2b44ec2 100644
--- a/.github/workflows/lint_python.yml
+++ b/.github/workflows/lint_python.yml
@@ -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
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 3e2e886c..26830a26 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -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
@@ -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:
@@ -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
diff --git a/HISTORY.rst b/HISTORY.rst
index 84544674..b8a5fcf1 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -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.
diff --git a/docs/source/parallel.rst b/docs/source/parallel.rst
index ce487f2a..9f8427b3 100644
--- a/docs/source/parallel.rst
+++ b/docs/source/parallel.rst
@@ -9,7 +9,7 @@ For example, it can be installed via `homebrew `_ on Mac OS::
brew install parallel
-Refer to the `GNU Parallel homepage `_ for more details on available packaes, source code, installation, and other documentation and tutorials.
+Refer to the `GNU Parallel homepage `_ for more details on available packages, source code, installation, and other documentation and tutorials.
Basic Usage
diff --git a/internetarchive/__init__.py b/internetarchive/__init__.py
index bbe10ca1..3a1e9df3 100644
--- a/internetarchive/__init__.py
+++ b/internetarchive/__init__.py
@@ -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',
]
diff --git a/internetarchive/api.py b/internetarchive/api.py
index 12c2d558..f97d5d41 100644
--- a/internetarchive/api.py
+++ b/internetarchive/api.py
@@ -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.
diff --git a/internetarchive/cli/__init__.py b/internetarchive/cli/__init__.py
index e227074c..ddab3fd0 100644
--- a/internetarchive/cli/__init__.py
+++ b/internetarchive/cli/__init__.py
@@ -40,8 +40,8 @@
)
__all__ = [
- "ia",
"cli_utils",
+ "ia",
"ia_configure",
"ia_copy",
"ia_delete",
diff --git a/internetarchive/cli/cli_utils.py b/internetarchive/cli/cli_utils.py
index a4aeaac2..e727498e 100644
--- a/internetarchive/cli/cli_utils.py
+++ b/internetarchive/cli/cli_utils.py
@@ -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]
diff --git a/internetarchive/files.py b/internetarchive/files.py
index 1a1031c0..673b5226 100644
--- a/internetarchive/files.py
+++ b/internetarchive/files.py
@@ -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,
diff --git a/internetarchive/iarequest.py b/internetarchive/iarequest.py
index bb800ec4..c3e51ccb 100644
--- a/internetarchive/iarequest.py
+++ b/internetarchive/iarequest.py
@@ -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, []))
diff --git a/internetarchive/item.py b/internetarchive/item.py
index e3edbd64..82b8eebc 100644
--- a/internetarchive/item.py
+++ b/internetarchive/item.py
@@ -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.
@@ -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.
diff --git a/internetarchive/session.py b/internetarchive/session.py
index 2362a089..c61a2891 100644
--- a/internetarchive/session.py
+++ b/internetarchive/session.py
@@ -68,7 +68,7 @@ class ArchiveSession(requests.sessions.Session):
Collection(identifier='nasa', exists=True)
"""
- ITEM_MEDIATYPE_TABLE = {
+ ITEM_MEDIATYPE_TABLE = { # noqa: RUF012
'collection': Collection,
}
@@ -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}'
diff --git a/internetarchive/utils.py b/internetarchive/utils.py
index 9d57bd61..c1683278 100644
--- a/internetarchive/utils.py
+++ b/internetarchive/utils.py
@@ -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
@@ -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):
diff --git a/pyproject.toml b/pyproject.toml
index 827d9792..03c3f27e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,4 +1,8 @@
[tool.ruff]
+line-length = 102
+target-version = "py37"
+
+[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
@@ -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"]
diff --git a/setup.cfg b/setup.cfg
index b8bffa46..e46756b3 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -8,7 +8,7 @@ url = https://github.com/jjjake/internetarchive
author = Jacob M. Johnson
author_email = jake@archive.org
license = AGPL-3.0
-license_file = LICENSE
+license_files = LICENSE
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
@@ -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
@@ -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
diff --git a/tests/conftest.py b/tests/conftest.py
index 1f0ef92c..38818cce 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -27,7 +27,6 @@
'nasa_meta.xml',
'nasa_reviews.xml',
'nasa_itemimage.jpg',
- 'globe_west_540_thumb.jpg',
'__ia_thumb.jpg',
}
@@ -90,20 +89,20 @@ 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:
@@ -111,17 +110,17 @@ def nasa_item():
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')
diff --git a/tests/requirements.txt b/tests/requirements.txt
index 0cf7ee05..dd975cf0 100644
--- a/tests/requirements.txt
+++ b/tests/requirements.txt
@@ -1,3 +1,3 @@
pytest==7.2.2
responses==0.23.1
-ruff==0.0.269
+ruff==0.8.5
diff --git a/tests/test_item.py b/tests/test_item.py
index 5492cd6c..2324ebb4 100644
--- a/tests/test_item.py
+++ b/tests/test_item.py
@@ -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'
diff --git a/tox.ini b/tox.ini
index 3ac17306..1d4cc439 100644
--- a/tox.ini
+++ b/tox.ini
@@ -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}