Skip to content

Commit

Permalink
Fix failing GitHub Actions
Browse files Browse the repository at this point in the history
Temporary workaround for https://pyup.io/v/51457/f17
  • Loading branch information
cclauss committed Dec 7, 2022
1 parent d6a820e commit 66b64f9
Show file tree
Hide file tree
Showing 8 changed files with 334 additions and 273 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/lint_python.yml

This file was deleted.

21 changes: 6 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,8 @@
# python: python3.10

repos:
#- repo: local
# hooks:
# - id: make-lint-diff
# name: make lint-diff
# entry: bash -c 'git diff master -U0 | ./scripts/flake8-diff.sh'
# language: python
# additional_dependencies:
# - flake8

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-builtin-literals
- id: check-executables-have-shebangs
Expand All @@ -40,7 +31,7 @@ repos:
rev: 22.10.0
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+
language_version: python3
args:
- --diff
- --skip-string-normalization
Expand All @@ -50,8 +41,8 @@ repos:
hooks:
- id: codespell # See setup.cfg for args

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -67,7 +58,7 @@ repos:
- --profile=black

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.990
rev: v0.991
hooks:
- id: mypy
additional_dependencies:
Expand All @@ -80,7 +71,7 @@ repos:
- types-urllib3

- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
rev: v3.3.0
hooks:
- id: pyupgrade
args:
Expand Down
6 changes: 3 additions & 3 deletions internetarchive/cli/ia_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ def main(argv, session: ArchiveSession) -> None:
try:
args = s.validate(args)
if args['--glob'] and args['--format']:
raise(SchemaError(None, '--glob and --format cannot be used together.'))
raise SchemaError(None, '--glob and --format cannot be used together.')
elif args['--exclude'] and args['--format']:
raise(SchemaError(None, '--exclude and --format cannot be used together.'))
raise SchemaError(None, '--exclude and --format cannot be used together.')
elif args['--exclude'] and not args['--glob']:
raise(SchemaError(None, '--exclude should only be used in conjunction with --glob.'))
raise SchemaError(None, '--exclude should only be used in conjunction with --glob.')

except SchemaError as exc:
print(f'{exc}\n{printable_usage(__doc__)}', file=sys.stderr)
Expand Down
58 changes: 36 additions & 22 deletions internetarchive/cli/ia_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,27 @@


def main(argv, session: ArchiveSession | None = None) -> None:
session = session or ArchiveSession()
args = docopt(__doc__, argv=argv)

# Validate args.
s = Schema({
str: Use(bool),
'<query>': Use(lambda x: ' '.join(x)),
'--parameters': Use(lambda x: get_args_dict(x, query_string=True)),
'--header': Or(None, And(Use(get_args_dict), dict),
error='--header must be formatted as --header="key:value"'),
'--sort': list,
'--field': list,
'--timeout': Use(lambda x: float(x[0]),
error='--timeout must be integer or float.')
})
s = Schema(
{
str: Use(bool),
'<query>': Use(lambda x: ' '.join(x)),
'--parameters': Use(lambda x: get_args_dict(x, query_string=True)),
'--header': Or(
None,
And(Use(get_args_dict), dict),
error='--header must be formatted as --header="key:value"',
),
'--sort': list,
'--field': list,
'--timeout': Use(
lambda x: float(x[0]), error='--timeout must be integer or float.'
),
}
)
try:
args = s.validate(args)
except SchemaError as exc:
Expand All @@ -86,13 +93,15 @@ def main(argv, session: ArchiveSession | None = None) -> None:
'timeout': args['--timeout'],
}

search = session.search_items(args['<query>'], # type: ignore
fields=fields,
sorts=sorts,
params=args['--parameters'],
full_text_search=args['--fts'],
dsl_fts=args['--dsl-fts'],
request_kwargs=r_kwargs)
search = session.search_items(
args['<query>'],
fields=fields,
sorts=sorts,
params=args['--parameters'],
full_text_search=args['--fts'],
dsl_fts=args['--dsl-fts'],
request_kwargs=r_kwargs,
)

try:
if args['--num-found']:
Expand All @@ -110,12 +119,17 @@ def main(argv, session: ArchiveSession | None = None) -> None:
except ValueError as e:
print(f'error: {e}', file=sys.stderr)
except ConnectTimeout as exc:
print('error: Request timed out. Increase the --timeout and try again.',
file=sys.stderr)
print(
'error: Request timed out. Increase the --timeout and try again.',
file=sys.stderr,
)
sys.exit(1)
except ReadTimeout as exc:
print('error: The server timed out and failed to return all search results,'
' please try again', file=sys.stderr)
print(
'error: The server timed out and failed to return all search results,'
' please try again',
file=sys.stderr,
)
sys.exit(1)
except AuthenticationError as exc:
print(f'error: {exc}', file=sys.stderr)
Expand Down
6 changes: 3 additions & 3 deletions internetarchive/cli/ia_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
import csv
import os
import sys
from pathlib import Path
import webbrowser
from copy import deepcopy
from locale import getpreferredencoding
from pathlib import Path
from tempfile import TemporaryFile

from docopt import docopt, printable_usage
Expand Down Expand Up @@ -146,8 +146,8 @@ def main(argv, session): # noqa: C901
'--header': Or(None, And(Use(get_args_dict), dict),
error='--header must be formatted as --header="key:value"'),
'--retries': Use(lambda x: int(x[0]) if x else 0),
'--sleep': Use(lambda l: int(l[0]), error='--sleep value must be an integer.'),
'--size-hint': Or(Use(lambda l: str(l[0]) if l else None), int, None,
'--sleep': Use(lambda lst: int(lst[0]), error='--sleep value must be an integer.'),
'--size-hint': Or(Use(lambda lst: str(lst[0]) if lst else None), int, None,
error='--size-hint value must be an integer.'),
'--status-check': bool,
})
Expand Down
2 changes: 1 addition & 1 deletion internetarchive/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
ReadTimeout,
RetryError,
)
from tqdm import tqdm
from tqdm.auto import tqdm

from internetarchive import auth, iarequest, utils

Expand Down
Loading

0 comments on commit 66b64f9

Please sign in to comment.