Restoreref2#408
Open
andreafrancia wants to merge 41 commits into
Open
Conversation
…can Faked in test instead of multiple funcionts.
The idea is to reduce the need of using doubles of internal collaborator of RestoreCmd and work almost only on the file system. The file system for tests for now is only a real fs, these changes will lead to ability to use also a fake fs. Other changes: - added tested features to FakeTrashDir - added features to MyPath
Modern mypy dropped Python 2 checking (removed in 0.980), so this pins an old mypy (0.971, the last version with --py2 support) in its own venv, along with the last Python-2-compatible release of the six stubs (later typeshed releases dropped Python 2 support too). psutil never had Python 2 stubs at all, so it's ignore-listed via a dedicated mypy config.
PermissionError doesn't exist in Python 2's builtins; the NameError catch already handles that correctly at runtime, but mypy's --py2 mode has no way to know the name is deliberately version-conditional.
The second loop reused the name "index" from the first loop over user-supplied strings. Old mypy (used for the Python 2 type-check) doesn't re-infer the type on reuse, so it kept treating the variable as str and flagged the later "in acceptable_values" (an xrange) check as invalid.
Scripts.__init__ used real PEP 3107 annotation syntax (fs: ScriptFs), which is a hard SyntaxError on Python 2.7 - it doesn't just fail type checking, it breaks collection for every test that transitively imports this module (18 collection errors in CI). Switched to the type-comment style already used everywhere else in this file.
print was passed as a bare callable (BumpCmd(os.system, print, ...)), which only works if print is a function rather than a statement. Add the future import so this actually works on Python 2.7 too.
I removed the .python-version file that seems to generate confusion while the "Test sdist creation" workflow run. The reported error is: Error: The version '3.10 3.14' with architecture 'x64' was not found for Ubuntu 24.04. Link to a recent failure: https://github.com/andreafrancia/trash-cli/actions/runs/29209351404/job/86694285276?pr=407
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.