Fix clean hook, linter, typing errors and windows build error#3
Merged
Conversation
Remove the Windows branch from normalize_path so it always returns forward slashes, consistent with the method's docstring. Input paths from hatchling's recurse_selected_project_files() are always POSIX format on all platforms, so the backslash conversion was unnecessary and broke test assertions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
TupleT, DictT, ListT, SetT, and ListStr were compat shims for pre-PEP 585 Python versions. With the minimum now at 3.10, all call sites can use builtins directly (list[str], dict[K, V], set[T], tuple[...]). Also cleaned up platform.py's stale __all__ and removed an unused Dict import. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The `options` property was decorated with `@memo`, which caches results in a closure dict keyed by `id(self)`. Python reuses memory addresses after GC, so a fresh CythonBuildHook instance created after the build hook was destroyed could get the same id, causing @memo to return a stale Config without re-executing the function body — silently skipping the `precompiled_extensions.add(".py")` side effect. Since `compile_py=True` is the default, this caused `included_files` to miss all .py-sourced files on the clean hook, leaving their generated .c/.so artifacts in place. Projects that compile only .py files (no .pyx) were fully unaffected by clean(). Fix: compute parse_from_dict() eagerly in __init__ and store as self._options, applying precompiled_extensions side effects there. The options property becomes a plain accessor. Also add FileNotFoundError handling around os.remove in clean() so that a second invocation (e.g. wheel + sdist targets) doesn't crash when files were already removed by the first call. Add test_clean_removes_generated_files which builds the src_structure project, forces GC (triggering potential memo ID reuse), then calls clean() on a fresh hook and asserts all .c/.so files are gone. Co-Authored-By: Claude Sonnet 4.6 <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.
No description provided.