Repository navigation
Python cleanup - #173
Open
slycordinator wants to merge 4 commits into
Open
Python cleanup#173slycordinator wants to merge 4 commits into
slycordinator wants to merge 4 commits into
Conversation
convert to use pathlib.Path for file operations * allows files to be opened directly with their own path object [file_path.open()] instead of the low-level open function [open(file_path)] * made extract_depo return list of Path objects * replaced os.makedirs(dir, exist_ok=True) with dir_path.mkdir(parents=True, exist_ok=True) * simplified looking for '.depot' files using pathlib.Path.rglob * remove/count path objects by checking Path.suffix
* moved solaar imports to head of file - arguably better for it to crash early before trying other operations * moved repeated/looped re.sub patterns into their own compiled patterns to be reused * changed file operations to use pathlib.Path instead of string paths
* generate-placholders.py - correct typo from previous * optionsplus_extractor/canonicalize.py - ruff changed the imports into alphabetical with capitals first * optionsplus_extractor/cli.py - ruff changed order of imports - replace Optional with typehint of "object | None" - use re.compile for slugify reuse * descriptor.py consolidate imports
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.
Python script cleanup
Replaces low level os library to use pathlib.Path for file operations and loop over pathlib.Path.rglob for files instead of using string paths or glob libary.
Replaces Optional[object] with object | None for hype hints
For repeated re.sub calls, uses re.compile early.
Reorders/condenses imports according to ruff
And in case of scripts/generate-placeholders.py, moves logitech_receiver imports early in script to fail before starting to work on other stuff (which would otherwise make the work pointless)