Skip to content

Update README, fix bugs from code review, switch to uv - #23

Merged
Bonajo merged 20 commits into
mainfrom
docs/update-readme
Sep 21, 2026
Merged

Bonajo merged 20 commits into
mainfrom
docs/update-readme

Conversation

@Bonajo

@Bonajo Bonajo commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Summary

The README no longer matched the code, so it was updated. A full code review then found a number of bugs and inconsistencies, which are fixed here one commit at a time. The project is also moved from Poetry to uv.

README

  • CLI table matches the real flags (-x, --dry-run, -e, -b, -u, -c format), plus supported comment styles and a Python module example.
  • "Adding a new tag" section fixed (close tag must be added to default_tags, class diagram names).

Bug fixes

  • -b/--binary and -u/--unknown now work on the command line (they were rejected by argparse and never passed on).
  • Unknown extension or binary file with fail: log the error and continue with the other files, then raise StripError at the end if fail_on_error (was: break, or a raw UnicodeDecodeError).
  • Uncomment: regex is built per comment style (was cached from the first style used), the open symbol is escaped, and the close symbol is removed for styles that have one (.xml, .ml).
  • --dry-run prints the stripped files to stdout (was only visible with -vv).
  • -c is validated (clear error), the extension is lowercased and the global comment mapping is no longer mutated.
  • get_working_directory resolves the path first, so -w ../x and symlinks cannot escape the current directory.
  • FileUtils no longer changes the process working directory, and glob characters in the working directory are handled.
  • Logger: no duplicate handlers on repeated calls, and verbosity of 4 or more clamps to debug.
  • Range tag errors report the real line number and a reason (e.g. "the range does not contain any lines").
  • cs:ignore only matches as a whole tag (cs:ignored no longer ignores the file).
  • Files are read and written as UTF-8.
  • Files in the output directory are skipped when it is a subdirectory of the working directory (a second run with **/*.java no longer strips the previous output).
  • Tokenizer state is per instance, and the tokenizer cache is keyed on the comment and the tag set, so custom tags added later are picked up.

Behaviour changes to be aware of

  • strip_files(..., fail_on_error=True) is now the default (same as the command line). Failing files raise StripError after all files are processed.
  • Files that are not valid UTF-8 are treated as binary.
  • New public StripError (exported from codestripper).
  • Python >=3.10 (CI already only tested 3.10 to 3.12).

Tooling

  • Poetry replaced by uv (pyproject.toml with [project], uv_build, uv.lock); workflows use astral-sh/setup-uv.
  • ruff added as linter (uv run ruff check, PyCharm-like settings, line length 120); unused imports and dead code removed.
  • pytest bumped to 9.1.1 (and pytest-cov to 7.1.0) to fix the /tmp/pytest-of-{user} vulnerability (pytest < 9.0.3).

Testing

136 tests pass locally (Python 3.14), mypy and ruff check are clean. Not yet run on Windows and macOS, and not on Python 3.10 to 3.12; CI will cover that. The release.yml workflow (uv build / uv publish) is untested.

@Bonajo
Bonajo merged commit 82dfac8 into main Sep 21, 2026
11 checks passed
@Bonajo
Bonajo deleted the docs/update-readme branch September 21, 2026 09:03
Bonajo added a commit that referenced this pull request Sep 21, 2026
## Summary
Same release pipeline as classroom and create-codegrade-assignment:

- **PR title check** (`pr-title.yml`, job `conventional title`): PR
titles must follow Conventional Commits, because with squash merging the
title becomes the commit on `main`.
- **Semantic release** (`semantic-release.yml` + `.releaserc.json`): on
every push to `main` the next version is determined from the commit
subjects, tagged `vX.Y.Z` and a GitHub release is created.
- **PyPI publish** (`pypi-publish.yml`, reusable): when a new version is
released, `uv version <version> --frozen`, `uv build` and `uv publish`
(with `PYPI_TOKEN`). The version is set at build time and not committed
back to `main`.
- **`release.yml`**: now only an escape hatch for manually pushed `v*`
tags, calling the same publish workflow. Tags pushed by semantic-release
(with `GITHUB_TOKEN`) do not trigger it, so nothing is published twice.
- **README**: new "Releases" section with the PR title conventions.

This PR is titled `feat:` on purpose: on merge, the first automated
release will be **v1.3.0** (the commits since v1.2.0 from #23 would
otherwise only give a patch release).

## Testing
Workflow files parse; locally `uv version 1.3.0 --frozen` + `uv build`
on a clean copy produces `codestripper-1.3.0` without changing
`uv.lock`. The release and PyPI upload can only be verified after merge.
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant