Custom Source Code Checks
summary
A custom flake8 plugin is implemented that parses files with Python’s ast module and flags any public function or method that uses positional or args instead of keyword-only parameters, handling Python 2 and 3 forms and ignoring a single leading self/cls in methods. The project (foobar + foobar_flakes) registers via setuptools entry points, runs under tox and returns flake8-style (line, column, message) failures. Key pieces: flake8 plugin, AST-based checks, tox + setuptools entry point*.
AI-written summary · about
chapters (14)
- 0:00Introduction to custom checks
- 1:23Why automate source checks
- 2:48Custom checks vs standard tools
- 6:41How Python processes code
- 8:27Working with AST in Python
- 10:12Finding function definitions
- 13:26Integrating with flake8
- 17:19Understanding function arguments
- 20:31Enforcing keyword-only args
- 23:23Customizing checks per project
- 24:49Running and fixing checks
- 25:10Setting up the environment
- 26:58Advantages of AST-based checks
- 27:42Q&A and resources
related talks
28mPreventing headaches with linters and automated checks
05mTool Confusion: Pythonic Code with flake8, tox and pre-commit
22mPublishing well formed Python packages
30mAutomating Code Quality
27mAn Overview of the Python Code Tool Landscape 2023
27mPython Linters at Scale
26mOpen Source on Easy Mode
21mTeach Your Old Code New Tricks: Automating Code Quality in Large Projects
