diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c0c53193..e55d087f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v6.0.0 hooks: - id: check-yaml - id: detect-private-key @@ -24,34 +24,34 @@ repos: - --markdown-linebreak-ext=md - repo: https://github.com/MarcoGorelli/auto-walrus - rev: v0.2.2 + rev: 0.4.1 hooks: - id: auto-walrus - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.2 + rev: v0.15.20 hooks: - id: ruff # See pyproject.toml for args # args: [--fix, --exit-non-zero-on-fix] - - repo: https://github.com/psf/black - rev: 24.2.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 26.5.1 hooks: - id: black # See pyproject.toml for args - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.4.2 hooks: - id: codespell # See pyproject.toml for args additional_dependencies: - tomli - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.7.0 + rev: v2.25.1 hooks: - id: pyproject-fmt - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.16 + rev: v0.25 hooks: - id: validate-pyproject diff --git a/BWBImportBot/__init__.py b/BWBImportBot/__init__.py index 043b3e38..557ccb99 100644 --- a/BWBImportBot/__init__.py +++ b/BWBImportBot/__init__.py @@ -1,10 +1,10 @@ #!/usr/bin/env python """ - __init__.py - ~~~~~~~~~~~ - :copyright: (c) 2020 by Internet Archive. - :license: AGPL v3 +__init__.py +~~~~~~~~~~~ +:copyright: (c) 2020 by Internet Archive. +:license: AGPL v3 """ __title__ = "bwbimportbot" diff --git a/ia-bulkmarc-bot/bulk-import.py b/ia-bulkmarc-bot/bulk-import.py index eb775585..788b26d4 100755 --- a/ia-bulkmarc-bot/bulk-import.py +++ b/ia-bulkmarc-bot/bulk-import.py @@ -1,12 +1,12 @@ #!/usr/bin/env python3 """ - Iterates over an archive.org bulk MARC item, such as OpenLibraries-Trent-MARCs, - and imports all records in all of its MARC files to Open Library. +Iterates over an archive.org bulk MARC item, such as OpenLibraries-Trent-MARCs, +and imports all records in all of its MARC files to Open Library. - USAGE: ./bulk-import.py +USAGE: ./bulk-import.py - Logs results to STDOUT +Logs results to STDOUT """ import argparse diff --git a/old-onix-bot/onix.py b/old-onix-bot/onix.py index d9a721c6..42fc9bac 100644 --- a/old-onix-bot/onix.py +++ b/old-onix-bot/onix.py @@ -105,7 +105,7 @@ def startElementNS(self, name, qname, attrs): self.subhandler.startElementNS(name, qname, attrs) self.subdepth += 1 else: - (uri, localname) = name + uri, localname = name if localname == "product": self.subhandler = xmltramp.Seeder(self.parser) self.subhandler.startElementNS(name, qname, attrs) diff --git a/old-onix-bot/sax_utils.py b/old-onix-bot/sax_utils.py index a4eb7e6c..d9ac45e5 100644 --- a/old-onix-bot/sax_utils.py +++ b/old-onix-bot/sax_utils.py @@ -121,7 +121,7 @@ def startElementNS(self, name, qname, attrs): if self.ignoring: self.ignoring += 1 else: - (uri, localname) = name + uri, localname = name c_maker = self.collector_table.get(localname) or self.collector_table.get( collector_any ) @@ -180,7 +180,7 @@ def __init__(self, collector_table): self.values = {} def collect(self, key_value): - (key, value) = key_value + key, value = key_value if self.values.get(key): raise Exception(f"dictionary key '{key}' is already mapped") else: diff --git a/old-onix-bot/thread_utils.py b/old-onix-bot/thread_utils.py index 064395be..3482923b 100644 --- a/old-onix-bot/thread_utils.py +++ b/old-onix-bot/thread_utils.py @@ -43,7 +43,7 @@ def re_raise(self): def ForeignException_extract(): - (exc_type, exc_value, exc_traceback) = sys.exc_info() + exc_type, exc_value, exc_traceback = sys.exc_info() return ForeignException(exc_type, exc_value, exc_traceback) diff --git a/old-onix-bot/urlcache.py b/old-onix-bot/urlcache.py index 09a5f63d..9767a53b 100644 --- a/old-onix-bot/urlcache.py +++ b/old-onix-bot/urlcache.py @@ -27,7 +27,7 @@ def get_entries(self): def get(self, url): url = url.strip() - (entries, next, index) = self.get_entries() + entries, next, index = self.get_entries() id = entries.get(url) if id is None: # with index locked, add an entry for this url and diff --git a/old-onix-bot/xmltramp.py b/old-onix-bot/xmltramp.py index d4e0471f..8c5df968 100644 --- a/old-onix-bot/xmltramp.py +++ b/old-onix-bot/xmltramp.py @@ -415,8 +415,7 @@ def unittest(): doc = Namespace("http://example.org/bar") bbc = Namespace("http://example.org/bbc") dc = Namespace("http://purl.org/dc/elements/1.1/") - d = parse( - """ @@ -424,8 +423,7 @@ def unittest(): John Polk John Palfrey Buffy - """ - ) + """) assert repr(d) == '...' assert ( diff --git a/pyproject.toml b/pyproject.toml index cc92b322..318938c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,26 +1,6 @@ [tool.ruff] -select = [ - "C4", # flake8-comprehensions - "C90", # mccabe - "E", # pycodestyle - "F", # Pyflakes - "I", # isort - "ICN", # flake8-import-conventions - "PGH", # pygrep-hooks - "PIE", # flake8-pie - "PLC", # Pylint conventions - "PLE", # Pylint errors - "PLR091", # Pylint refactor just for max-args, max-branches, etc. - "PYI", # flake8-pyi - "RSE", # flake8-raise - "RUF", # Ruff-specific rules - "T10", # flake8-debugger - "TCH", # flake8-type-checking - "TID", # flake8-tidy-imports - "UP", # pyupgrade - "W", # pycodestyle - "YTT", # flake8-2020 -] +target-version = "py37" +line-length = 616 ignore = [ "E402", "E722", @@ -31,20 +11,34 @@ ignore = [ "PLC1901", "RUF001", ] -line-length = 616 -target-version = "py37" - -[tool.ruff.mccabe] -max-complexity = 21 - -[tool.ruff.pylint] -max-args = 8 -max-branches = 18 -max-statements = 73 - -[tool.ruff.per-file-ignores] -"test/*" = ["S101"] +mccabe.max-complexity = 21 +per-file-ignores."test/*" = [ "S101" ] +pylint.max-args = 8 +pylint.max-branches = 18 +pylint.max-statements = 73 +select = [ + "C4", # flake8-comprehensions + "C90", # mccabe + "E", # pycodestyle + "F", # Pyflakes + "I", # isort + "ICN", # flake8-import-conventions + "PGH", # pygrep-hooks + "PIE", # flake8-pie + "PLC", # Pylint conventions + "PLE", # Pylint errors + "PLR091", # Pylint refactor just for max-args, max-branches, etc. + "PYI", # flake8-pyi + "RSE", # flake8-raise + "RUF", # Ruff-specific rules + "T10", # flake8-debugger + "TCH", # flake8-type-checking + "TID", # flake8-tidy-imports + "UP", # pyupgrade + "W", # pycodestyle + "YTT", # flake8-2020 +] [tool.codespell] -ignore-words-list = 'didnt' -skip = './.*,*.xsd' +ignore-words-list = "didnt" +skip = "./.*,*.xsd"