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
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 KeyErrors 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
Description
This PR refactors a few operations to make the code handle edge cases efficiently with marginal performance improvements.
Type of change
Changelog
async_data
inShellTheme
since its members are immutable.async_data
later.Gio.File.make_directory_with_parents
with Python's builtinos.makedirs
withexist_ok
as True to implicitly create directories when nonexistent.KeyError
s when accessing dictionary values, theget
method is used to supply a default value.get
method (which may returnNone
) is coupled with the nullishor
operator to use the value that is notNone
.main_source
attribute as argument to the_compile_sass
function.None
..close()
s on file handles when using context managers.Testing
How to test the changes
Just run
./local.sh