Development setup
Before you start, ensure you have:- Python 3.12+ installed
- uv package manager installed
- Git repository cloned
Install dependencies
From the repository root:typer- CLI frameworkruff- Linter and formattermypy- Static type checkertaskipy- Task runner
Code quality
Linting
Check your code for style issues:Formatting
Format code to match project style:- Line length: 120 characters
- Quote style: double quotes
- Target: Python 3.12
Type checking
Run static type analysis:- Python version: 3.12
warn_return_any: enabledwarn_unused_ignores: enabled
Run all checks
Run the full check suite:- Linting (
ruff check) - Format check (
ruff format --check) - Type checking (
mypy)
All checks must pass before submitting a pull request. The CI will run these checks automatically.
Linting rules
The project uses these ruff rules:- E - pycodestyle errors (PEP 8 violations)
- F - Pyflakes (undefined names, unused imports)
- I - isort (import sorting)
- N - pep8-naming (naming conventions)
- W - pycodestyle warnings
- UP - pyupgrade (modern Python syntax)
GitHub Actions integration
The CLI is used in several GitHub Actions workflows:Contribution Approved workflow
.github/workflows/contribution_approved.yml
approved label is added to an issue
Outputs used:
commit_message- For commit messagecommit_email- For contributor attributioncommit_username- For contributor attributionerror_message- On failure
Update READMEs workflow
.github/workflows/update_readmes.yml
- On changes to
listings.json - Manually via workflow_dispatch
commit_message- For commit message
Lint workflow
.github/workflows/lint.yml
.py, pyproject.toml)
GitHub Actions outputs
When writing commands that run in GitHub Actions, use theset_output helper:
commit_message- Suggested commit messagecommit_email- Email for git commit attributioncommit_username- Username for git commit attributionsummary_comment- Comment to post on issue (for bulk operations)error_message- Error details on failure
Contribution workflow
-
Create a feature branch
-
Make your changes
- Edit code in
main.pyorlist_updater/ - Follow existing code style and patterns
- Use type hints for all function parameters and returns
- Edit code in
-
Test your changes
-
Run code quality checks
-
Commit your changes
-
Push and create pull request
Then open a pull request on GitHub.
Coding guidelines
File organization
- main.py - Only CLI command definitions (Typer decorators)
- list_updater/commands.py - Core commands (readme, contribution, mark-inactive, remove)
- list_updater/analytics.py - Analytics commands (stats, validate, search, diff, fix)
- list_updater/category.py - Category-related logic
- list_updater/listings.py - Data loading and filtering
- list_updater/formatter.py - Output formatting
- list_updater/github.py - GitHub Actions integration
- list_updater/constants.py - Configuration and constants
Naming conventions
- Commands:
cmd_<group>_<action>(e.g.,cmd_listings_search) - Internal helpers:
_<name>with underscore prefix (e.g.,_extract_urls) - Public API: Exported in
__init__.py
Type hints
Always use type hints:str | Noneinstead ofOptional[str]list[dict[str, Any]]instead ofList[Dict[str, Any]]
Docstrings
Use Google-style docstrings:Error handling
For GitHub Actions commands, usefail() for errors:
Adding new commands
1. Implement the command function
Add tolist_updater/commands.py or list_updater/analytics.py:
2. Export from init.py
Add tolist_updater/__init__.py:
3. Add CLI command in main.py
Add tomain.py:
4. Test the command
Best practices
- Keep commands focused - Each command should do one thing well
- Use existing utilities - Reuse functions from
listings.py,formatter.py, etc. - Validate input early - Check parameters before doing expensive operations
- Provide helpful output - Use emojis and formatting for readability
- Handle errors gracefully - Show clear error messages
- Follow existing patterns - Look at similar commands for consistency
Getting help
If you have questions:- Check the Project Structure documentation
- Look at existing commands for examples
- Create a miscellaneous issue on GitHub
Related documentation
- Project Structure - Understand the codebase
- Testing - Test your changes
- Installation - Setup for contributors