All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
All references below to the variable tv
indicate an instance of
TempVars
that has been bound as
with TempVars(...) as tv:
...
This release should not affect the behavior of the package in any way.
- Remove duplicative call to
inspect.currentframe()
inTempVars._ns_default
- Replace custom
copy_if_not_none()
inner function with built-incopy.copy()
, in__attrs_post_init__()
- Refactor the temporary variable popping operations to
a more concise form in both
__enter__()
and__exit__()
- Switched to
black
-style code formatting - Switched source file headers from comment blocks to module docstrings
- Relocated some commentary from code comments to method docstrings
TempVars
now emits a warning if it is instantiated without masking pattern arguments.
TempVars().names
changed to be an exact copy of the__init__
argument names. The actual variables masked can be retrieved astv.stored_nsvars.keys()
.- Since, due to the above, initialization of
names
as a new, empty list is no longer needed, its default was changed toNone
- The
globals()
namespace stored asTempVars.ns
has been renamed to._ns
to discourage fiddling with it. TempVars
changed to be an@attr.s(slots=True)
class.
TempVars.passed_names
has been completely removed.
starts
andends
no longer allow patterns that respectively start and end with__
, to avoid munging the default dunder objects in the namespace- If a variable referencing a list, rather than a list literal, is
passed as
names
, that passed reference is no longer erroneously updated with matches to thestarts
andends
patterns. - Fixed an erroneous duplication of variable names held in
names
due to variables in the namespace, e.g., matching multiple pattern entries instarts
and/orends
.
- Created the
TempVars
context manager - Implemented hard prevention of use in other than global scopes
(raises
RuntimeError
) due to known improper behavior - Implemented masking of specific variables with
names
argument - Implemented
.startswith
/.endswith
pattern-based masking viastarts
andends
arguments - Implemented option to restore or not masked namespace variables
via
restore
argument - Implemented storage of pre-existing masked namespace variables
for use within the managed context (
TempVars.stored_nsvars
) - Implemented storage of temporary variables and values assigned
within the managed context (
TempVars.retained_tempvars
) for use after exiting the suite