python package starter project template#1
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR implements a complete project scaffolding system for PyPlatez. It adds a CLI command ( ChangesProject Scaffolding and Release
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
hatch_build.py (1)
18-23: ⚡ Quick winMake template inclusion deterministic.
Iterating
root.iterdir()unsorted can produce non-reproducible wheel contents across environments. Sort by name before populatingforce_include.Proposed fix
- for item in root.iterdir(): + for item in sorted(root.iterdir(), key=lambda p: p.name):🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@hatch_build.py` around lines 18 - 23, The template inclusion loop is nondeterministic because it iterates root.iterdir() unsorted; change the loop that builds force_include (the for over root.iterdir(), with checks against EXCLUDE and creation of dest and force_include[str(item)] = dest) to iterate items sorted by name (e.g., sort by item.name) so entries are added in a stable order and wheel contents become reproducible.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@hatch_build.py`:
- Around line 1-25: The file fails CI due to formatting; run the project's
formatter (ruff format) or apply the same style changes to satisfy ruff so the
file is reformatted. Open the BuildHook class and its initialize method
(symbols: BuildHook, initialize, EXCLUDE, force_include) and reformat
spacing/indentation and trailing whitespace, fix the inline comment style and
alignment around assignments and control blocks to match the project's ruff
configuration, then re-run ruff format until no changes are reported and commit
the formatted hatch_build.py.
In `@src/pyplatez/cli.py`:
- Around line 1-54: The file fails CI due to formatting; run the project's
formatter (ruff format or configured formatter) on this file to reformat
imports, spacing and line breaks so it matches the repo style, then re-run
tests; focus your changes around the scaffold and main functions and any
top-level imports to ensure ruff no-longer flags "ruff format would reformat
this file".
- Around line 47-49: The code currently calls target.iterdir() which raises
NotADirectoryError if --path points to a file; update the check in
src/pyplatez/cli.py to first test target.exists() and target.is_dir() (or
!target.is_dir()) before calling target.iterdir(): if target.exists() and not
target.is_dir(), print a clear error about the path being a file and exit;
otherwise, if target.is_dir() and any(target.iterdir()), keep the existing
"already exists and is not empty" behavior. Ensure you use the same target,
is_dir(), and iterdir() symbols so the fix is easy to locate.
- Around line 40-52: Validate and/or normalize the provided project name before
using it to create the package directory: in the CLI flow handling args.command
== "init" (where args.name, target, scaffold(...) and target.mkdir(...) are
used) check that args.name is a valid Python identifier and not a reserved
keyword (use str.isidentifier() and keyword.iskeyword()) and reject with a clear
stderr message and non-zero exit if invalid; alternatively implement a
normalization step (e.g., replace hyphens with underscores, strip/replace path
separators, ensure it doesn't start with a digit) and use the normalized name
for the package directory while preserving the original project display name.
Ensure this validation/normalization occurs before constructing target and
calling scaffold.
---
Nitpick comments:
In `@hatch_build.py`:
- Around line 18-23: The template inclusion loop is nondeterministic because it
iterates root.iterdir() unsorted; change the loop that builds force_include (the
for over root.iterdir(), with checks against EXCLUDE and creation of dest and
force_include[str(item)] = dest) to iterate items sorted by name (e.g., sort by
item.name) so entries are added in a stable order and wheel contents become
reproducible.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: fb3df6a2-2a97-429d-91dc-1acd10e26dc4
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
.github/workflows/build.yml.gitignoreREADME.mdhatch_build.pypyproject.tomlsrc/pyplatez/cli.py
Please describe the changes this PR makes and why it should be merged:
Status and versioning classification:
Summary by CodeRabbit
New Features
pyplatez initCLI command to scaffold new projects with customizable names and paths.Chores