Feat/type checker - #1637
Conversation
Naramsim
left a comment
There was a problem hiding this comment.
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.
| try: | ||
| git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"], stderr=subprocess.DEVNULL).decode().strip() | ||
| except Exception: | ||
| except (subprocess.CalledProcessError, OSError, ValueError): |
There was a problem hiding this comment.
Do we need to be so precise here? catching Exception is bad?
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Great, I left some comments/questions. The remaining file that I need to review is serializers.py
e6aafb1 to
1484bb5
Compare
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:
performance boosts across the board with serializer and django orm query optimizations with the ditto process completing in 8mins compared to 26~ mins in circleci currently more benchmarks in the gist and optimizations done https://app.circleci.com/pipelines/github/PokeAPI/pokeapi/2617/workflows/729700bf-568b-4cf7-8566-0d4399c07ed9/jobs/7002
verified that new payloads by server are 100% same as before via a local script
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