-
Notifications
You must be signed in to change notification settings - Fork 47
Update linters and adjust code #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
f30d939
5089686
19c9122
cb65227
70725b9
d76c0ef
7559ebb
dfcd6c8
e04ed75
d72d924
51c3294
6d5cdda
bb07147
8b5dcea
0f27d27
63f6002
ecd790f
a97c17e
f1468d4
33649e3
244c189
37ad1fa
ae44f9d
afc2a5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| API_KEY= | ||
| API_SECRET= | ||
| AFFILIATE_TAG= | ||
| COUNTRY_CODE= |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #! /bin/bash -e | ||
|
|
||
| docker build \ | ||
| --build-arg TAG="3.12" \ | ||
| --build-arg UID="$(id -u)" \ | ||
| --build-arg GID="$(id -g)" \ | ||
| -t python-amazon-paapi . | ||
|
|
||
| touch .env | ||
|
|
||
| docker run -t --rm -u "$(id -u):$(id -g)" -v "${PWD}:/code" --env-file .env \ | ||
| python-amazon-paapi -c "python -m pre_commit" | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,9 +8,9 @@ assignees: '' | |
| --- | ||
|
|
||
| **Steps to reproduce** | ||
| 1. | ||
| 2. | ||
| 3. | ||
| 1. | ||
| 2. | ||
| 3. | ||
|
|
||
| **Code example** | ||
| ```python | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,73 +2,118 @@ name: Lint and test | |||||
|
|
||||||
| on: | ||||||
| push: | ||||||
| pull_request: | ||||||
| types: [opened, reopened] | ||||||
|
|
||||||
| permissions: | ||||||
| pull-requests: read | ||||||
|
|
||||||
| jobs: | ||||||
| env: | ||||||
| API_KEY: ${{ secrets.API_KEY }} | ||||||
| API_SECRET: ${{ secrets.API_SECRET }} | ||||||
| AFFILIATE_TAG: ${{ secrets.AFFILIATE_TAG }} | ||||||
| COUNTRY_CODE: ${{ secrets.COUNTRY_CODE }} | ||||||
|
|
||||||
| isort: | ||||||
| jobs: | ||||||
| ruff: | ||||||
| runs-on: ubuntu-latest | ||||||
| container: | ||||||
| image: python:3.12 | ||||||
| steps: | ||||||
| - name: Check out code | ||||||
| uses: actions/checkout@v4 | ||||||
| - name: Install dependencies | ||||||
| run: pip install isort | ||||||
| - name: Check imports order | ||||||
| run: isort -c . | ||||||
| run: pip install ruff | ||||||
| - name: Check code errors | ||||||
| run: ruff check --output-format=github . | ||||||
|
|
||||||
| black: | ||||||
| mypy: | ||||||
| runs-on: ubuntu-latest | ||||||
| container: | ||||||
| image: python:3.12 | ||||||
| steps: | ||||||
| - name: Check out code | ||||||
| uses: actions/checkout@v4 | ||||||
| - name: Install dependencies | ||||||
| run: pip install black | ||||||
| - name: Check code format | ||||||
| run: black --check --diff --color . | ||||||
| run: pip install mypy | ||||||
|
||||||
| run: pip install mypy | |
| run: pip install -e . && pip install mypy |
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test job dependency chain is inverted. The jobs are configured so that test-py37 needs test-py38, which needs test-py39, which needs test-py310, which needs test-py311, which needs test-py312. This creates a reverse dependency chain where the oldest Python version depends on the newest one, causing jobs to run sequentially in reverse order (3.12 → 3.11 → 3.10 → 3.9 → 3.8 → 3.7).
If the intent is to run tests in parallel without dependencies, remove all needs statements. If the intent is to fail fast when a test fails on the latest version first, make test-py37 through test-py311 depend on test-py312 instead of creating a chain.
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,58 @@ | ||||||||||||
| # See https://pre-commit.com for more information | ||||||||||||
| # See https://pre-commit.com/hooks.html for more hooks | ||||||||||||
| default_language_version: | ||||||||||||
| python: python3.12 | ||||||||||||
|
|
||||||||||||
| repos: | ||||||||||||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||||||||||||
| rev: v4.6.0 | ||||||||||||
| hooks: | ||||||||||||
| - id: trailing-whitespace | ||||||||||||
| - id: end-of-file-fixer | ||||||||||||
| - id: mixed-line-ending | ||||||||||||
| - id: check-yaml | ||||||||||||
| - id: check-added-large-files | ||||||||||||
| - id: check-ast | ||||||||||||
| - id: check-executables-have-shebangs | ||||||||||||
| - id: check-shebang-scripts-are-executable | ||||||||||||
| - id: check-toml | ||||||||||||
| - id: name-tests-test | ||||||||||||
|
|
||||||||||||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||||||||||||
| rev: v0.6.9 | ||||||||||||
| hooks: | ||||||||||||
| - id: ruff | ||||||||||||
| args: [--fix, --exit-non-zero-on-fix] | ||||||||||||
| - id: ruff-format | ||||||||||||
|
|
||||||||||||
| - repo: https://github.com/lk16/detect-missing-init | ||||||||||||
| rev: v0.1.6 | ||||||||||||
| hooks: | ||||||||||||
| - id: detect-missing-init | ||||||||||||
| args: ["--create", "--python-folders", "amazon_paapi"] | ||||||||||||
|
|
||||||||||||
| - repo: https://github.com/pre-commit/mirrors-mypy | ||||||||||||
| rev: 'v1.11.2' | ||||||||||||
| hooks: | ||||||||||||
| - id: mypy | ||||||||||||
| exclude: sdk/ | ||||||||||||
|
|
||||||||||||
| - repo: local | ||||||||||||
| hooks: | ||||||||||||
| - id: mypy | ||||||||||||
| name: Checking types with mypy | ||||||||||||
| language: system | ||||||||||||
| entry: "python -m mypy amazon_paapi" | ||||||||||||
| pass_filenames: false | ||||||||||||
|
Comment on lines
+42
to
+46
|
||||||||||||
| - id: mypy | |
| name: Checking types with mypy | |
| language: system | |
| entry: "python -m mypy amazon_paapi" | |
| pass_filenames: false |
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two hooks with the same ID test (lines 48 and 54). Pre-commit hook IDs must be unique within the configuration. The second hook should have a different ID, such as coverage or test-coverage.
| - id: test | |
| - id: coverage |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| ARG TAG="3.12" | ||
|
|
||
| FROM python:${TAG} | ||
|
|
||
| ARG UID="1000" | ||
| ARG GID="1000" | ||
|
|
||
| ENV PRE_COMMIT_HOME="/code/.cache/pre-commit" | ||
| ENV PRE_COMMIT_COLOR="always" | ||
|
|
||
| RUN groupadd --gid ${GID} user \ | ||
| && useradd --uid ${UID} --gid user --shell /bin/bash --create-home user | ||
|
|
||
| USER user | ||
|
|
||
| WORKDIR /code | ||
|
|
||
| RUN pip install --no-cache-dir \ | ||
| coverage \ | ||
| mypy \ | ||
| pre-commit \ | ||
| pytest \ | ||
| ruff | ||
|
|
||
| COPY setup.py setup.py | ||
| COPY README.md README.md | ||
| RUN pip install --no-cache-dir -e . | ||
|
|
||
| ENTRYPOINT [ "bash" ] |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,34 @@ | ||||||
| export UID:=$(shell id -u) | ||||||
| export GID:=$(shell id -g) | ||||||
|
|
||||||
| export PYTHON_TAGS = 3.7 3.8 3.9 3.10 3.11 3.12 | ||||||
|
|
||||||
| setup: | ||||||
| @git config --unset-all core.hooksPath || true | ||||||
| @git config --local core.hooksPath .githooks | ||||||
|
|
||||||
| build: | ||||||
| @docker build --build-arg TAG="3.12" --build-arg UID="${UID}" --build-arg GID="${GID}" -t python-amazon-paapi . | ||||||
|
|
||||||
| coverage: build | ||||||
| @touch .env | ||||||
| @docker run -t --rm -u "${UID}:${GID}" -v "${PWD}:/code" --env-file .env python-amazon-paapi -c \ | ||||||
| "python -m coverage run -m pytest -rs && python -m coverage xml && python -m coverage report" | ||||||
|
|
||||||
| test: build | ||||||
| @touch .env | ||||||
| @docker run -t --rm -u "${UID}:${GID}" -v "${PWD}:/code" --env-file .env python-amazon-paapi -c "python -m pytest -rs" | ||||||
|
|
||||||
| test-all-python-tags: | ||||||
| @touch .env | ||||||
| @for tag in $$PYTHON_TAGS; do \ | ||||||
| docker build --build-arg TAG="$$tag" --build-arg UID="${UID}" --build-arg GID="${GID}" -t python-amazon-paapi .; \ | ||||||
| docker run -t --rm -u "${UID}:${GID}" -v "${PWD}:/code" python-amazon-paapi -c "python -m pytest -rs"; \ | ||||||
| done | ||||||
|
|
||||||
| lint: build | ||||||
| @touch .env | ||||||
| @docker run --rm -t -u "${UID}:${GID}" -v "${PWD}:/code" --env-file .env python-amazon-paapi -c "python -m pre_commit run -a" | ||||||
|
||||||
| @docker run --rm -t -u "${UID}:${GID}" -v "${PWD}:/code" --env-file .env python-amazon-paapi -c "python -m pre_commit run -a" | |
| @docker run --rm -t -u "${UID}:${GID}" -v "${PWD}:/code" --env-file .env python-amazon-paapi -c "pre-commit run -a" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command
python -m pre_commitis incorrect. The correct module name ispre_commitwith an underscore, but when running as a module, it should be invoked aspython -m pre_commit runto execute the hooks. The current command will likely fail with an error about running pre-commit as a module.