Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
- run:
name: Install deps
command: make install
- run:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in another comment, the pre-commit checks include a full "build-and-test" run. Adding it to the CI would be re-doing these tests?

Would it make sense to leave this off of the pre-commit altogether and otherwise leave the Makefile as-is?

@FallenDeity FallenDeity Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok great - I mentioned this in the other comment. Thanks for the clarification!

name: Pre-commit checks
command: SKIP=ruff-format uv run pre-commit run --all-files --show-diff-on-failure
- run:
name: Format Check
command: make format-check
Expand Down
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ docker-compose*
target
data/v2/cries
data/v2/csv
data/v2/sprites
data/v2/sprites
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ about: Create a report to help us improve
Thanks for contributing to the PokéAPI project. To make sure we're effective, please check the following:

- Make sure your issue hasn't already been submitted on the issues tab. (It has search functionality!)
- If your issue is one of outdated API data, please note that we get our data from [veekun](https://github.com/veekun/pokedex/). If they are not up to date either, please look for or create an issue there. Otherwise, feel free to create an issue here.
- If your issue is one of outdated API data, please note that we get our data from [veekun](https://github.com/veekun/pokedex/). If they are not up to date either, please look for or create an issue there. Otherwise, feel free to create an issue here.
- Provide a clear description of the issue.
- Provide a clear description of the steps to reproduce.
- Provide a clear description of the expected behavior.
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

blank_issues_enabled: false
contact_links:
- name: Question
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ about: Suggest an idea for this project
<!--
Please search existing issues to avoid creating duplicates.
Describe the feature you'd like.
Describe the feature you'd like.
Thank you!
-->
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ updates:
- package-ecosystem: "docker"
directory: "/Resources/docker/app"
schedule:
interval: "monthly"
interval: "monthly"
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Thank you for submitting a Pull Request. Please:
<!-- Thank you for submitting a Pull Request. Please:
* Ensure that the code is up-to-date with the `master` branch.
* Include a description of the proposed changes and how to test them.
* Consider adding the `no-deploy` label if this PR shouldn't be deployed and does not alter the data served by the API.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-k8s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ jobs:
- name: Assert containers running
run: |
last_command=$(docker ps | grep 'pokeapi-' | wc -l)
test "$last_command" -eq 5
test "$last_command" -eq 5
60 changes: 60 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-ast
- id: check-json
- id: check-toml
- id: check-yaml
args:
- --allow-multiple-documents
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: pretty-format-json
args:
- --no-sort-keys
- --no-ensure-ascii
- id: sort-simple-yaml
- id: trailing-whitespace
args:
- --markdown-linebreak-ext=md

# TODO: Enable in the future when adding the ruff linter
# - repo: https://github.com/pre-commit/pygrep-hooks
# rev: v1.9.0
# hooks:
# - id: python-check-blanket-noqa
# - id: python-check-blanket-type-ignore
# - id: python-use-type-annotations

- repo: local
hooks:
- id: check-csv
name: Check CSV
entry: uv run ./Resources/scripts/check_csv.py
language: system
args: [--encoding, utf-8]
files: \.csv$

- id: ruff-format
name: Ruff Format
entry: uv run ruff format .
language: system
types_or: [python, pyi]
pass_filenames: false

- id: build-and-test
name: Build and Test
entry: >-
python -c "
import subprocess, sys;
run = lambda cmd, inp=None: subprocess.run(cmd, input=inp, text=True).returncode == 0 or sys.exit(1);
run(['uv', 'run', 'manage.py', 'migrate', '--settings=config.local']);
run(['uv', 'run', 'manage.py', 'shell', '--settings=config.local'], inp='from data.v2.build import build_all; build_all()\n');
run(['uv', 'run', 'manage.py', 'test', '--settings=config.local'])
"
language: system
pass_filenames: false
always_run: true
stages: [manual]
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ git checkout -b my_new_branch
```
- Write some code, fix something, and add a test to prove that it works. **No pull request will be accepted without tests passing, or without new tests if new features are added.**

- Make sure your code passes the pre-commit hooks, if you have the hooks installed it should run automatically on commit. You can run them manually with:
```bash
make pre-commit
# or
uv run pre-commit run --all-files
```

- Commit your code and push it to GitHub

- [Open a new pull request](https://help.github.com/articles/creating-a-pull-request/) and describe the changes you have made.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Paul Hallett paulandrewhallett@gmail.com
Zane Adickes zaneadix@gmail.com
Charles Marttinen charlesmarttinen.ca
Sargun Vohra sargun.vohra@gmail.com
Alessandro Pezzè igougi.ui@gmail.com
Alessandro Pezzè igougi.ui@gmail.com
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ install: check-uv # Install requirements for local development
install-base: check-uv # Install minimal requirements for runtime/pipeline environments
uv sync --locked --no-dev

pre-commit-install: check-uv # Install pre-commit hooks

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get rid of this target? isn't pre-commit installed along the other dependencies?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that dosent install pre-commit the dependency but pre-commit the hook so whenever you next run git commit the pre commit checks defined in the config file automatically run

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, got it! Ok, so, I don't want the hook on git. Or maybe to have it more complicated I'd like to have it only when uv is installed. I don't want to force everyone to install uv. If a contributor needs to submit a small PR not touching the python logic I'd like not to force the contributor to install all the necessary tools (python, uv, deps)

@jemarq04 @phalt what do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but arent both make install and make pre-commit-install optional like you decide whether to run it or not, although I get your point once the hooks are installed you need to run pre-commit uninstall to remove them if you want to in your next minor change or commit with --no-verify flag to skip the hooks

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think forcing pre-commit on everyone is a difficult sell.

But if we can have an optional path of using pre-commit with git, that is good with me :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes we've already implemented do require uv to run things locally, which I think is a perfectly fine step forward. (I was using it myself as I didn't want to globally install some of the dependencies for this project!)

As far as pre-commit, the targets in the makefile seem like the right way to go. I usually like running it manually, so I'd skip the pre-commit-install target and just run it directly, which is possible with this setup. I like it!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I can also specify explicitly in the readme/contributing md files that installing the hooks into git hooks is optional and add an emphasis that you can run it manually too so new contributors don't get confused if they aren't too familiar with pre-commit

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, looking at the .pre-commit-config.yaml file, having it run automatically with every commit might be intensive! There's a check that builds and tests the entire database, which can be very lengthy. Having that run every time you commit may be too much. Maybe leave this off as a target and if someone wants it they can run pre-commit directly to install the hooks to git?

@FallenDeity FallenDeity Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/PokeAPI/pokeapi/pull/1602/changes#diff-63a9c44a44acf85fea213a857769990937107cf072831e1a26808cfde9d096b9R60 the build and test is marked as manual so it doesn't run every commit rest of the stuff is just formatting checks where all of them together take like 3-5secs

to run a manual hook you need to explicitly invoke via a pre-commit hook id as such pre-commit run <hook_id> --all-files or via hook stage for all manual stages

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, I was unfamiliar with the manual key and didn't process that. With that in mind disregard my last comment - I think the pre-commit checks are great and having the install and run be separate targets is a good way to go. Thank you for clarifying!

uv run pre-commit install

pre-commit: check-uv # Run pre-commit hooks
uv run pre-commit run --all-files

setup: check-uv # Set up the project database
uv run manage.py migrate ${local_config}

Expand Down Expand Up @@ -89,10 +95,10 @@ docker-prod:
docker-setup: docker-up docker-migrate docker-build-db # (Docker) Start services, prepare the latest DB schema, populate the DB

format: check-uv # Format the source code
uv run black . --extend-exclude '.+/scripts/.+'
uv run ruff format .

format-check: check-uv # Check the source code has been formatted
uv run black . --check --extend-exclude '.+/scripts/.+'
uv run ruff format . --check

pull:
git checkout master
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ A RESTful API for Pokémon - [pokeapi.co](https://pokeapi.co)
- Download this source code into a working directory, be sure to use the flag `--recurse-submodules` to clone also our submodules.

- Install [uv](https://docs.astral.sh/uv/getting-started/installation/) for Python environment management.

- Install the requirements using the Makefile commands:

```sh
make install
# This will install all the required packages and libraries for using PokeAPI
```

- Install the pre-commit hooks using the Makefile commands:

```sh
make pre-commit-install
```

- Set up the local development environment using the following command:

```sh
Expand Down
2 changes: 1 addition & 1 deletion Resources/gcp/api_v2_slo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ CREATE_SLO_POST_BODY=$(cat <<EOF
EOF
)

curl --http1.1 --header "Authorization: Bearer $ACCESS_TOKEN" --header "Content-Type: application/json" -X POST -d "$CREATE_SLO_POST_BODY" "https://monitoring.googleapis.com/v3/projects/$GOOGLE_CLOUD_PROJECT/services/_1QdRovaRBGqDhnMI8i2Yw/serviceLevelObjectives"
curl --http1.1 --header "Authorization: Bearer $ACCESS_TOKEN" --header "Content-Type: application/json" -X POST -d "$CREATE_SLO_POST_BODY" "https://monitoring.googleapis.com/v3/projects/$GOOGLE_CLOUD_PROJECT/services/_1QdRovaRBGqDhnMI8i2Yw/serviceLevelObjectives"
2 changes: 1 addition & 1 deletion Resources/k8s/kustomize/base/config/pokeapi.env.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ADMINS=PokeAPI,change.me@pokeapi.co
BASE_URL=http://localhost/
POKEAPI_CHECKOUT_REF=master
POKEAPI_CHECKOUT_REF=master
2 changes: 1 addition & 1 deletion Resources/k8s/kustomize/base/secrets/graphql.env.sample
Original file line number Diff line number Diff line change
@@ -1 +1 @@
HASURA_GRAPHQL_ADMIN_SECRET=pokeapi-change-me
HASURA_GRAPHQL_ADMIN_SECRET=pokeapi-change-me
2 changes: 1 addition & 1 deletion Resources/k8s/kustomize/base/secrets/postgres.env.sample
Original file line number Diff line number Diff line change
@@ -1 +1 @@
POSTGRES_PASSWORD=pokeapi-change-me
POSTGRES_PASSWORD=pokeapi-change-me
2 changes: 1 addition & 1 deletion Resources/kind/config-ga.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ nodes:
- role: control-plane
extraMounts:
- hostPath: /home/runner/work/pokeapi/pokeapi/data/v2/
containerPath: /code/pokeapi/data/v2/
containerPath: /code/pokeapi/data/v2/
2 changes: 1 addition & 1 deletion Resources/nginx/ssl/ssl.sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ ssl_session_tickets off;

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
ssl_prefer_server_ciphers off;
51 changes: 51 additions & 0 deletions Resources/scripts/check_csv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import argparse
import csv
import locale
import typing
from concurrent.futures import ThreadPoolExecutor, as_completed


def check_csv(filename: str, encoding: str, delimiter: str) -> tuple[str, bool, str]:
try:
with open(filename, encoding=encoding, newline='') as f:
reader = csv.reader(f, delimiter=delimiter)
first_len = None
for line_no, row in enumerate(reader, start=1):
if first_len is None:
first_len = len(row)
elif len(row) != first_len:
message = f'line {line_no}: contains inconsistent columns (expected {first_len}, got {len(row)})'
return filename, False, message
except UnicodeDecodeError:
return filename, False, f'failed to decode csv text file using {encoding!r}'

return filename, True, ''


def main(argv: typing.Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('-e', '--encoding', dest='encoding', default=locale.getpreferredencoding())
parser.add_argument('-d', '--delimiter', dest='delimiter', default=',')
parser.add_argument('-j', '--jobs', dest='jobs', type=int, default=8)
parser.add_argument('filenames', nargs='*', help='Filenames to check.')
args = parser.parse_args(argv)

print(f'Checking CSV files using encoding {args.encoding!r} and delimiter {args.delimiter!r}...')
print(f'Checking {len(args.filenames)} files with {args.jobs} workers...')

retval = 0
with ThreadPoolExecutor(max_workers=args.jobs) as executor:
futures = {
executor.submit(check_csv, filename, args.encoding, args.delimiter): filename
for filename in args.filenames
}
for future in as_completed(futures):
filename, ok, msg = future.result()
if not ok:
print(f'{filename}: {msg}')
retval = 1
return retval


if __name__ == '__main__':
raise SystemExit(main())
4 changes: 2 additions & 2 deletions Resources/scripts/data/gen8/read_swsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def __OpenTbl(this, path):
with open(path, "rb") as f:
try:
# First four bytes is "magic"; needs to be 0x42544841
testMagic = struct.unpack("<I", f.read(4))[0]
testMagic = struct.unpack("<I", f.read(4))[0]
if (testMagic == this.__magic):
# Next four bytes is the number of entries to read
count = struct.unpack("<I", f.read(4))[0]
Expand All @@ -211,4 +211,4 @@ def __ReadUntil(this, f, value):
string += c.decode("utf-8")
c = f.read(1)

return string
return string
2 changes: 1 addition & 1 deletion Resources/scripts/data/gen8/to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@
writer.writerow(header)
entriesList.sort()
writer.writerows(entriesList)
print("Done")
print("Done")
2 changes: 1 addition & 1 deletion Resources/scripts/data/scraper_go/data/new_abilities.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ Steam Engine (Ability)
Steely Spirit (Ability)
Transistor (Ability)
Unseen Fist (Ability)
Wandering Spirit (Ability)
Wandering Spirit (Ability)
2 changes: 1 addition & 1 deletion Resources/scripts/data/scraper_go/data/new_moves.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@ Terrain Pulse (move)
Thunder Cage (move)
Thunderous Kick (move)
Triple Axel (move)
Wicked Blow (move)
Wicked Blow (move)
2 changes: 1 addition & 1 deletion Resources/scripts/data/scraper_go/data/new_pokemon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ Wooloo_(Pok%C3%A9mon)
Yamper_(Pok%C3%A9mon)
Zacian_(Pok%C3%A9mon)
Zamazenta_(Pok%C3%A9mon)
Zarude_(Pok%C3%A9mon)
Zarude_(Pok%C3%A9mon)
2 changes: 1 addition & 1 deletion Resources/scripts/data/scraper_node/new_pokemons.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ module.exports.new_pokemons = [
"Zacian",
"Zamazenta",
"Zarude"
]
]
2 changes: 1 addition & 1 deletion Resources/scripts/wait.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ wait_for_http() {
fi
}

wait_for_http "${1:-http://localhost/api/v2/}"
wait_for_http "${1:-http://localhost/api/v2/}"
4 changes: 1 addition & 3 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@
}
}

SECRET_KEY = os.environ.get(
"SECRET_KEY", "django-insecure-a(!_5+l3$#l1f4n!x+&ns_+8$4q@df*3rh$n#2h@l$2gti7!7-"
)
SECRET_KEY = os.environ.get("SECRET_KEY", "django-insecure-a(!_5+l3$#l1f4n!x+&ns_+8$4q@df*3rh$n#2h@l$2gti7!7-")

CUSTOM_APPS = ("pokemon_v2",)

Expand Down
Loading
Loading