Skip to content

refactor: PEP-518 and use uv #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

goodtune
Copy link

@goodtune goodtune commented Jun 7, 2025

Everything is working well locally, will need to see what happens in GitHub Actions and likely will need to make some tune-ups.

I made this to modernise the codebase, as I have another contribution I'd like to make and falling back to old tools was making life harder.

Summary by CodeRabbit

  • Chores
    • Migrated project configuration to use pyproject.toml and removed legacy setup files (setup.py, setup.cfg, requirements.txt, etc.).
    • Updated .gitignore to track .python-version and added ignore rules for generated documentation files.
    • Added .python-version specifying Python 3.12.
    • Updated contributor information in AUTHORS.md.
    • Improved and modernized contributing guidelines, including updated commands and expanded supported Python versions.
    • Added and documented new linting and formatting configurations.
    • Enhanced test environment support for newer Python and PyPy versions.
    • Updated Makefiles to use the uv tool for development tasks.
  • Documentation
    • Updated documentation configuration to use dynamic version retrieval and improved build instructions.
    • Added an "Unreleased" section to the project history.

Everything is working well locally, will need to see what happens in GitHub Actions and likely will need to make some tune-ups.
Copy link

coderabbitai bot commented Jun 7, 2025

Walkthrough

The project migrated to a PEP 518-compliant build and development workflow centered around pyproject.toml and the uv tool. Legacy files for requirements, setup, and manifest were removed. Tooling and documentation were updated to reflect new commands and supported Python versions. Linting, testing, and packaging configurations were modernized and consolidated.

Changes

Files / Grouped Paths Change Summary
.flake8 Added configuration to exclude docs from linting and set max line length to 120.
.gitignore Stopped ignoring .python-version files.
.python-version Added to specify Python 3.12 as the desired interpreter version.
AUTHORS.md Added "Gary Reynolds" as a contributor.
CONTRIBUTING.md Updated instructions: modernized commands, clarified steps, expanded supported Python versions.
HISTORY.md Added "Unreleased" section noting PEP 518/pyproject.toml/uv migration.
MANIFEST.in, requirements.txt,
requirements_dev.txt, setup.cfg,
setup.py, docs/requirements.txt
Deleted legacy packaging, requirements, and manifest files.
Makefile, docs/Makefile Changed all Python/tool invocations to use uv run or uv commands; updated clean target order in Makefile.
django_datadog_logger/__init__.py Removed __version__ declaration.
docs/.gitignore Added ignore rules for generated .rst files.
docs/conf.py Switched version retrieval to use importlib.metadata instead of module attribute.
pyproject.toml Added full build, metadata, dependencies, and tool configuration compliant with PEP 518.
tox.ini Expanded environment list, switched to uv-venv-lock-runner, modernized test and lint environments.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant Shell/CI
    participant uv
    participant Python/Tools

    Developer->>Shell/CI: Run make/lint/test/docs commands
    Shell/CI->>uv: Execute via uv run/sync/build/publish
    uv->>Python/Tools: Launch Python, tox, sphinx, etc.
    Python/Tools-->>uv: Perform requested actions
    uv-->>Shell/CI: Return results
    Shell/CI-->>Developer: Output/logs
Loading

Poem

In the garden of code, a fresh breeze blows,
Old files are compost, and new standards grow.
With uv and pyproject, we hop to the sun,
Linting and testing, all modernly done!
🐇✨
Now every bunny can build and run.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@goodtune
Copy link
Author

goodtune commented Jun 7, 2025

@coderabbitai review

Copy link

coderabbitai bot commented Jun 7, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (10)
.flake8 (1)

1-3: Centralized Flake8 config—good start
Consolidating lint rules in a dedicated .flake8 file aligns with PEP-518 workflows. Consider extending the exclude list to also omit common directories like .git, __pycache__, build, dist, and any Django migration folders to streamline lint checks.

AUTHORS.md (1)

9-9: Add new contributor entry
Welcome Gary Reynolds. For Markdown clarity, remove the backslashes escaping the angle brackets so the entry reads:

-   Gary Reynolds <[email protected]>
HISTORY.md (1)

3-6: Document the PEP-518 migration under "Unreleased"
Good to track the shift to PEP-518 and uv. Remember to relocate and timestamp this entry under the next release version when cutting the actual release.

docs/conf.py (1)

26-26: Remove unused direct module import
import django_datadog_logger is no longer used for version retrieval. You can safely delete this import to reduce confusion.

🧰 Tools
🪛 Ruff (0.11.9)

26-26: django_datadog_logger imported but unused

Remove unused import: django_datadog_logger

(F401)

CONTRIBUTING.md (1)

54-60: Format URL step as a proper list/code block
The standalone URL under step 1 isn’t clearly styled. Consider indenting it under the numbered step or wrapping it in a code block to match the style of the subsequent shell snippets.

tox.ini (1)

24-29: Unify flake8 runner configuration
You’ve set both dependency_groups = pep8 (which pulls in flake8 via pyproject) and a standalone deps = flake8. To avoid duplicate installs, drop the extra deps line and rely solely on the pep8 group.

pyproject.toml (1)

53-56: Broaden Black target versions
The [tool.black] configuration currently targets only py37 and py38, but the project supports up to 3.13. Please update target-version to cover all supported Python versions.

Makefile (3)

24-27: Strong adoption of uv runner; consider DRY improvements
You’ve updated the BROWSER and help targets to use uv run python -c, which aligns perfectly with the new PEP-518 workflow. To reduce repetition and simplify future updates, consider defining a UV := uv run variable and then referencing $(UV) throughout.

Example diff:

+# Define uv runner for DRY usage
+UV := uv run

-BROWSER := uv run python -c "$$BROWSER_PYSCRIPT"
+BROWSER := $(UV) python -c "$$BROWSER_PYSCRIPT"

60-63: Coverage target modernization
The coverage commands have been ported to use uv run, and the HTML report is automatically opened with the configured BROWSER. This streamlines the workflow. Consider caching the .coverage data in CI between runs if build times become a concern.


68-74: Sphinx docs and live-reload targets updated
Switching sphinx-apidoc and watchmedo to run under uv maintains consistency across your tooling. For faster incremental builds, you might consider caching the Sphinx virtual environment or build artifacts in CI.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 187a2f9 and e9f2204.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • .flake8 (1 hunks)
  • .gitignore (0 hunks)
  • .python-version (1 hunks)
  • AUTHORS.md (1 hunks)
  • CONTRIBUTING.md (2 hunks)
  • HISTORY.md (1 hunks)
  • MANIFEST.in (0 hunks)
  • Makefile (2 hunks)
  • django_datadog_logger/__init__.py (0 hunks)
  • docs/.gitignore (1 hunks)
  • docs/Makefile (1 hunks)
  • docs/conf.py (2 hunks)
  • pyproject.toml (1 hunks)
  • requirements.txt (0 hunks)
  • requirements_dev.txt (0 hunks)
  • setup.cfg (0 hunks)
  • setup.py (0 hunks)
  • tox.ini (1 hunks)
💤 Files with no reviewable changes (7)
  • django_datadog_logger/init.py
  • .gitignore
  • requirements_dev.txt
  • requirements.txt
  • MANIFEST.in
  • setup.cfg
  • setup.py
🔇 Additional comments (8)
.python-version (1)

1-1: Pin local Python version to 3.12
Specifying 3.12 here matches the tox environment. If you intend to standardize on both 3.12 and 3.13 for local development, consider updating this to 3.13 or documenting the discrepancy.

docs/Makefile (1)

6-6: Use uv to invoke Sphinx—consistent update
Switching to uv run -m sphinx aligns with the new tooling. Ensure that uv is installed in your documentation CI environment and that any other Makefile targets invoking Python are similarly updated.

docs/.gitignore (1)

1-3: Looks good, doc artifacts appropriately ignored.
The new patterns will correctly prevent generated Sphinx .rst files from being committed.

CONTRIBUTING.md (1)

75-80: Align testing instructions with updated workflow
You reference make test-all, but the Makefile now wraps commands with uv run. Please confirm that make test-all remains available and correctly calls uv run tox, or update these instructions to uv run tox directly.

pyproject.toml (1)

31-36: Validate package name casing
The dependency "JSON-log-formatter" uses uppercase; PyPI names are normalized lowercase. Confirm this matches the actual package name—if not, switch to "json-log-formatter".

Makefile (3)

29-29: Clean target covers all artifact types
The clean rule now invokes clean-test, clean-build, and clean-pyc in sequence to remove test, build, coverage, and byte-compiled artifacts. This comprehensive cleanup looks solid.


51-57: Unified linting and testing via uv run
All lint (flake8), quick test, and full-matrix test targets now call through uv run, ensuring consistent environment resolution. Please verify that tox profiles (especially for Django tests) correctly pick up DJANGO_SETTINGS_MODULE when invoked via uv run.


77-84: Publishing and installation aligned with uv
Replacing twine upload and setup.py commands with uv publish, uv build, and uv sync --frozen adheres to the PEP-518 build backend. Please verify in your CI environment that uv publish handles credentials, signing, and metadata correctly.

@goodtune goodtune marked this pull request as ready for review June 7, 2025 05:34
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
pyproject.toml (1)

30-35: Include importlib-metadata for Python < 3.8
The code uses importlib.metadata under the hood, but the backport isn’t declared in the runtime dependencies.

 dependencies = [
+    "importlib-metadata; python_version<'3.8'",
     "backports.zoneinfo; python_version<'3.9'",
     "Django",
     "djangorestframework",
     "JSON-log-formatter",
 ]
🧹 Nitpick comments (2)
pyproject.toml (2)

31-35: Pin minimal version constraints for core dependencies
Unbounded "Django", "djangorestframework", and "JSON-log-formatter" may introduce breakages when new major versions are released. Consider specifying minimal and upper-bound versions, for example:

"Django>=3.2,<5.0",
"djangorestframework>=3.12,<4.0",
"JSON-log-formatter>=0.4,<1.0",

64-67: Align Black’s target-version with supported Python versions
Black is currently targeting only py37 and py38, yet the project classifiers include 3.9–3.13. Either expand target-version or remove it to default to all supported interpreters.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9f2204 and 44ac123.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • pyproject.toml (1 hunks)
🔇 Additional comments (1)
pyproject.toml (1)

40-46: uv tool not declared despite summary claiming its use
The PR description references a switch to uv, but there’s no uv entry in dependency-groups or a [tool.uv] section. Please clarify how uv is intended to be installed or configured.

Likely an incorrect or invalid review comment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
pyproject.toml (1)

30-36: Runtime dependencies: Consider version constraints.

It's recommended to add explicit version ranges for Django, djangorestframework, and JSON-log-formatter to avoid unintended breakages on upstream releases.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c806802 and 76b138d.

📒 Files selected for processing (3)
  • Makefile (2 hunks)
  • pyproject.toml (1 hunks)
  • tox.ini (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Makefile
🧰 Additional context used
🧠 Learnings (1)
tox.ini (1)
Learnt from: goodtune
PR: namespace-ee/django-datadog-logger#42
File: tox.ini:19-23
Timestamp: 2025-06-07T05:44:02.382Z
Learning: When using tox-uv with the uv-venv-lock-runner (specified as `runner = uv-venv-lock-runner` in tox.ini), dependencies are automatically installed from the uv.lock file, so explicit `deps` declarations in the [testenv] section are not required.
🔇 Additional comments (11)
tox.ini (4)

8-13: Expanded test matrix for new Python versions: Approve.

The envlist now covers Python 3.12, 3.13 and multiple PyPy interpreters, aligning with the supported versions in pyproject.toml. This will help catch compatibility issues early.


15-17: Add tox-uv requirement at the top-level: Valid.

Requiring tox-uv in the [tox] section is necessary to activate the uv-venv-lock-runner plugin.


19-22: Use uv-venv-lock-runner and updated test command: Good update.

Switching to runner = uv-venv-lock-runner and invoking django-admin test directly simplifies the workflow and leverages dependencies from uv.lock.


24-26: Refactored flake8 environment: Approve.

Using dependency_groups = pep8 and targeting specific paths is consistent with the new .flake8 setup.

pyproject.toml (7)

1-3: PEP 518 compliance: build-system section is correct.

The requires and build-backend entries ensure compatibility with PEP 517 frontends.


5-13: Project metadata: Well-defined.

Package name, description, README linkage, Python requirement, license, and author info are accurately declared.


14-29: Keywords and classifiers: Comprehensive coverage.

The keywords, development status, audience, and supported Python & implementation classifiers match the intended compatibility and project status.


41-52: Dependency groups: Docs and dev correctly set up.

The docs group includes the necessary Sphinx and parser versions and the backport for importlib-metadata on older Pythons; the dev group covers essential tooling.


53-57: PEP8 tooling group: Adequate.

Including black, flake8, and isort covers formatting and style enforcement.


59-63: setuptools configuration: Correct.

Specifying packages, disabling zip safety, and including package data aligns with the previous setup.


66-68: Black configuration: Aligned with new line length and Python targets.

line-length = 120 and updated target-version entries ensure consistency across code formatting tools.

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.

1 participant