From 2a26172ce5fabce9e1346974632fb899c5b489f8 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Fri, 31 Oct 2025 21:23:23 -0600 Subject: [PATCH 1/2] bump pre-commit deps --- .envrc | 45 ----------------------------------------- .pre-commit-config.yaml | 8 ++++---- 2 files changed, 4 insertions(+), 49 deletions(-) delete mode 100644 .envrc diff --git a/.envrc b/.envrc deleted file mode 100644 index 31e2911..0000000 --- a/.envrc +++ /dev/null @@ -1,45 +0,0 @@ - -set +u - -[ -f "$HOME/.envrc" ] && source_env $HOME || true - -export_alias() { - local name=$1 - shift - local alias_dir=$PWD/.direnv/aliases - local target="$alias_dir/$name" - mkdir -p "$alias_dir" - PATH_add "$alias_dir" - echo "#!/usr/bin/env bash" > "$target" - echo "set -e" >> "$target" - echo "$@ \"\$@\"" >> "$target" - chmod +x "$target" -} - -export_function() { - local name=$1 - local alias_dir=$PWD/.direnv/aliases - mkdir -p "$alias_dir" - PATH_add "$alias_dir" - local target="$alias_dir/$name" - if declare -f "$name" >/dev/null; then - echo "#!/usr/bin/env bash" > "$target" - declare -f "$name" >> "$target" 2>/dev/null - echo "$name" >> "$target" - chmod +x "$target" - fi -} - -export PROJECT_NAME=keepa - -export PYENV_VIRTUALENV_DISABLE_PROMPT=1 - -PATH_add "$PWD" - -PYENV_ROOT=$(pyenv root) -if [[ -d "${PYENV_ROOT}/versions/$PROJECT_NAME" ]]; then - eval "$(pyenv init -)" - pyenv activate $PROJECT_NAME -fi - -unset PS1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d2d91be..0407ebf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,12 +5,12 @@ ci: autoupdate_schedule: quarterly repos: - repo: https://github.com/keewis/blackdoc - rev: v0.4.1 + rev: v0.4.5 hooks: - id: blackdoc files: \.py$ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.12.2 + rev: v0.14.3 hooks: - id: ruff-check args: [--fix, --exit-non-zero-on-fix] @@ -28,12 +28,12 @@ repos: additional_dependencies: [toml] exclude: tests/ - repo: https://github.com/asottile/pyupgrade - rev: v3.20.0 + rev: v3.21.0 hooks: - id: pyupgrade args: [--py39-plus, --keep-runtime-typing] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: check-merge-conflict - id: debug-statements From ce7c6d2c23706e7c3b4af19ab19fe478a01d67cb Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Fri, 31 Oct 2025 21:47:04 -0600 Subject: [PATCH 2/2] fix domain check --- .github/workflows/testing-and-deployment.yml | 2 +- pyproject.toml | 4 ++-- src/keepa/interface.py | 4 ++-- tests/test_interface.py | 17 +++++++++-------- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/testing-and-deployment.yml b/.github/workflows/testing-and-deployment.yml index 0e22dd4..5f9100b 100644 --- a/.github/workflows/testing-and-deployment.yml +++ b/.github/workflows/testing-and-deployment.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] + python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] env: KEEPAKEY: ${{ secrets.KEEPAKEY }} diff --git a/pyproject.toml b/pyproject.toml index 2b574ae..d8a08b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,11 +14,11 @@ classifiers = [ "Intended Audience :: End Users/Desktop", "Topic :: Database :: Front-Ends", "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13" + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14" ] dependencies = [ "numpy >=1.9.3", diff --git a/src/keepa/interface.py b/src/keepa/interface.py index a6ed91c..13a3f2c 100644 --- a/src/keepa/interface.py +++ b/src/keepa/interface.py @@ -375,14 +375,14 @@ class Domain(Enum): BR = "BR" -def _domain_to_dcode(domain: Union[str, Domain]) -> int: +def _domain_to_dcode(domain: str | Domain) -> int: """Convert a domain to a domain code.""" if isinstance(domain, Domain): domain_str = domain.value else: domain_str = domain - if domain not in DCODES: + if domain_str not in DCODES: raise ValueError(f"Invalid domain code {domain}. Should be one of the following:\n{DCODES}") return DCODES.index(domain_str) diff --git a/tests/test_interface.py b/tests/test_interface.py index ecb686a..986d2d9 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -10,9 +10,9 @@ import keepa from keepa import keepa_minutes_to_time +from keepa import Keepa # reduce the request limit for testing - keepa.interface.REQLIM = 2 path = os.path.dirname(os.path.realpath(__file__)) @@ -89,11 +89,11 @@ # open connection to keepa @pytest.fixture(scope="module") -def api(): - return keepa.Keepa(TESTINGKEY) +def api() -> Keepa: + return Keepa(TESTINGKEY) -def test_deals(api): +def test_deals(api: Keepa) -> None: deal_parms = { "page": 0, "domainId": 1, @@ -319,16 +319,17 @@ def test_productquery_offers_multiple(api): assert np.isin(asins, PRODUCT_ASINS).all() -def test_domain(api): - asin = "0394800028" - request = api.query(asin, history=False, domain="BR") +def test_domain(api: Keepa) -> None: + """A domain different than the default.""" + asin = "3492704794" + request = api.query(asin, history=False, domain=keepa.Domain.DE) product = request[0] assert product["asin"] == asin def test_invalid_domain(api): with pytest.raises(ValueError): - api.query(PRODUCT_ASIN, history=False, domain="XX") + api.query(PRODUCT_ASIN, domain="XX") def test_bestsellers(api):