Skip to content

Feat/type checker - #1637

Open
FallenDeity wants to merge 13 commits into
PokeAPI:masterfrom
FallenDeity:feat/type-checker
Open

Feat/type checker#1637
FallenDeity wants to merge 13 commits into
PokeAPI:masterfrom
FallenDeity:feat/type-checker

Conversation

@FallenDeity

@FallenDeity FallenDeity commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Change description

I have written a detailed write up of the changes and decisions made for this pr in the gist u can find here and supporting details, please do give it a read summarizes all the changes nicely
https://gist.github.com/FallenDeity/aa36487a214ea4c40809949a6ccffe7b

here is a tldr for a quick overview

TLDR

This PR introduces critical performance optimizations, type safety, and linting standards to the codebase:

image
  • ruff lint all files and type out the django api surface with no errors reported, build and test py files left for future todo to limit scope of typing

Given there is some logical changes i would encourage checking it out locally perhaps running it too for better reviewing, I have tested the pr extensively and there shouldnt be any issues but feel free to request changes, the test and build process havent been modified only logical changes are to serializer.py and tests are running fine so this dosent introduce any regressions

AI coding assistance disclosure

Used some AI for analysis of serializers, some more exploration about django serializers and scripting/visualization to facilitate testing and diff across dumps

Contributor check list

  • I have written a description of the contribution and explained its motivation.
  • I have written tests for my code changes (if applicable).
  • I have read and understood the AI Assisted Contribution guidelines.
  • I will own this change in production, and I am prepared to fix any bugs caused by my code change.

@Naramsim Naramsim left a comment

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.

Hi Fallen! Thanks for the big and important PR! I reviewed some files and asked some questions.

Note: I didn't review nor take a glimpse at openapi.yml, tests.py, serializers.py, models.py, api.py yet.

Comment thread .github/workflows/code-quality.yml Outdated
Comment thread .github/workflows/code-quality.yml
Comment thread .github/workflows/database.yml
Comment thread config/__init__.py
Comment thread config/asgi.py
Comment thread config/settings.py Outdated
Comment thread config/settings.py Outdated
Comment thread config/settings.py Outdated
Comment thread data/v2/build.py Outdated
Comment thread pokemon_v2/migrations/0032_alter_pokemonevolution_time_of_day.py
Comment thread pokemon_v2/migrations/0032_evolution_condition_and_form_updates.py
Comment thread pokemon_v2/api.py
Comment thread pokemon_v2/api.py
Comment thread pokemon_v2/api.py
try:
git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"], stderr=subprocess.DEVNULL).decode().strip()
except Exception:
except (subprocess.CalledProcessError, OSError, ValueError):

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.

Do we need to be so precise here? catching Exception is bad?

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.

well a general rule of thumb is we never almost want a base exception anywhere because say for example subprocess someone entered an extra s as typo it would catch that too, basically just ends up masking errors which otherwise couldve been avoided by being specifc. another benefit is by having a specific error its so much clearer to the reader what could possibly go wrong and what cases are accounted for

also ruff lint throws an error when we have a blind exception https://docs.astral.sh/ruff/rules/blind-except/

@Naramsim Naramsim left a comment

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.

Great, I left some comments/questions. The remaining file that I need to review is serializers.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants