Adopt src-layout and rename the package to lowercase#14
Merged
Conversation
Audited the repo layout against PEP 8 and PyPA packaging guidance. Two of the findings were real defects rather than style: - The console script and `python -m` diverged. [project.scripts] pointed at `cli:main`, bypassing `__main__.run()`, so Ctrl+C during `pyfetch GET ...` produced a raw traceback and exit 0xC000013A while `python -m PyFetch` printed "Operation cancelled by user" and exited 0. The entry point now points at `pyfetch.__main__:run` and both paths behave identically. - No PEP 561 marker. The package has been mypy --strict clean for a while, but without `py.typed` every downstream type checker silently ignored all of its annotations. Added, plus a CI step asserting it ships in the wheel. Conventions: - BREAKING: the import package is now `pyfetch`, not `PyFetch` (PEP 8: "Python packages should also have short, all-lowercase names"). It was the sole outlier -- the repo directory, the GitHub remote, the console script and the built wheel all normalise to lowercase already. No compatibility shim; bumped to 2.0.0 and documented the one-line migration. - Moved the package under `src/` per the PyPA src-layout recommendation, so tests exercise the installed distribution rather than the working directory. - Pinned argparse `prog="pyfetch"`; the console script previously rendered its usage line as the interpreter path. - mypy excludes build/ and dist/, which otherwise collide with src/ as a duplicate `pyfetch` module after a build. Added CHANGELOG.md, CONTRIBUTING.md (documenting the layout, the naming rules, and the retry-testing pitfall) and .editorconfig. Verified: ruff, ruff format, mypy strict clean; 38 tests pass; 10-case CLI smoke run passes; wheel builds as pyfetch-2.0.0-py3-none-any.whl containing py.typed; benchmarks unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Audited the repo layout against PEP 8 and PyPA packaging guidance. Seven findings; two were real defects, not style.
Verified defects
1. The console script and
python -mdiverged.[project.scripts]pointed atPyFetch.cli:main, bypassing__main__.run(). Measured before the fix:pyfetch GET ...0xC000013Apython -m PyFetchOperation cancelled by user, exit 0Two entry points, two behaviours. The entry point now targets
pyfetch.__main__:run; both paths are identical.2. No PEP 561 marker. The package has been
mypy --strictclean for a while, but withoutpy.typedevery downstream type checker silently ignored all of its annotations. Added, plus a CI step asserting it actually ships in the wheel.Convention fixes
3. The package directory was CapWords. PEP 8: "Python packages should also have short, all-lowercase names."
PyFetch/was the sole outlier — the repo directory, the GitHub remote, the console script, and the built wheel (pyfetch-1.1.0-py3-none-any.whl, normalized per PEP 503/625) were all lowercase already.4. Flat layout rather than
src/. Without src-layout,import PyFetchfrom the repo root resolves to the source tree rather than the installed package, so tests can pass against code that was never installed.5–7. Added
CHANGELOG.md,CONTRIBUTING.md,.editorconfig. Pinned argparseprog="pyfetch"— the console script previously rendered its usage line as the interpreter path.Layout
Breaking change
The import package is renamed. Bumped to 2.0.0; no compatibility shim, per the decision to keep the tree clean:
Only the import path changes — the distribution name, console script, and wheel name are unaffected because they already normalized to lowercase.
Also fixed
mypynow excludesbuild/anddist/. Without it, running a build and thenmypy .fails withDuplicate module named "pyfetch"— which I hit during this work.Testing
ruff format --check, mypy strict all clean.usage: pyfetch).pyfetch-2.0.0-py3-none-any.whland containspyfetch/py.typed; CI now enforces this.🤖 Generated with Claude Code