This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor shell theming module (#806)
## Description This PR refactors a few operations to make the code handle edge cases efficiently with marginal performance improvements. ## Type of change - [ ] Bugfix (Change which fixes an issue) - [ ] New feature (Change which adds new functionality) - [x] Enhancement (Change which slightly improves existing code) - [ ] Breaking change (This change will introduce incompatibility with existing functionality) ## Changelog <!-- This is optional, but highly appreciated. --> - Stores the comma separated string representation of valid versions for later use in raising exceptions. - Uses tuple for `async_data` in `ShellTheme` since its members are immutable. - Uses tuple decomposition to assign theme variant and preset from `async_data` later. - Replaces `Gio.File.make_directory_with_parents` with Python's builtin `os.makedirs` with `exist_ok` as True to implicitly create directories when nonexistent. - Instead of relying on `KeyError`s when accessing dictionary values, the `get` method is used to supply a default value. - When a key might exist in one dictionary, the `get` method (which may return `None`) is coupled with the nullish `or` operator to use the value that is not `None`. - Uses predefined `main_source` attribute as argument to the `_compile_sass` function. - Uses the walrus operator to scope a template match to the condition when it is not `None`. - Removes unnecessary implicit `.close()`s on file handles when using context managers. ## Testing - [x] I have tested my changes and verified that they work as expected <!-- Make sure you did this step before marking your PR as ready for merge. --> ### How to test the changes <!-- Optional, it can speed up review process if you provide the information on how to test your changes. --> Just run `./local.sh`
- Loading branch information
Showing
1 changed file
with
34 additions
and
82 deletions.
There are no files selected for viewing
This file contains 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