Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(commons): deduplicate logic to keep behavior consistent [#14] #15

Merged
merged 4 commits into from
Jul 6, 2024

Conversation

rmlibre
Copy link
Owner

@rmlibre rmlibre commented Jul 6, 2024

Description

Detailed in (#14)

Expected behavior

Detailed in (#14)

Remediations

  • Make changes compatible with existing usage

The __contains__ logic also needed to be fixed to allow the simplification in this commit. Checking hasattr wasn't a limiting enough condition, as anything in the class dictionary would also return True. This led to errors when using namespaces as modules, because they'd take in attribute names like __doc__ which would proc a PermissionError in frozen classes.

  • Test that buggy behavior is no longer present

This that the frozen functionality is consistently applied across the various interfaces & class hierarchies.

async def test_frozen_state_is_enforced(self) -> None:
problem = ( # fmt: skip
"A mutation was allowed on a frozen object."
)
if not self._frozen:
return
obj = self._type(self._items)
with Ignore(PermissionError, if_else=violation(problem)):
obj.__init__(self._items)
obj = self._type(self._items)
for name, value in self._items.items():
with Ignore(PermissionError, if_else=violation(problem)):
obj[name] = value

Resolution related to (#9, #11, #14)

…#14]

The ``__contains__`` logic also needed to be fixed to allow the
simplification in this commit. Checking ``hasattr`` wasn't a limiting
enough condition, as anything in the class dictionary would also
return ``True``. This led to errors when using namespaces as modules,
because they'd take in attribute names like ``__doc__`` which would
proc a ``PermissionError`` in frozen classes.

Resolution related to (#9, #11, #14)
@rmlibre rmlibre added bug Something isn't working notice attention is advised, discussion is welcome labels Jul 6, 2024
@rmlibre rmlibre self-assigned this Jul 6, 2024
@rmlibre rmlibre changed the title [DRAFT] v0.23.10: fix(commons): deduplicate logic to keep behavior consistent [#14] fix(commons): deduplicate logic to keep behavior consistent [#14] Jul 6, 2024
@rmlibre rmlibre marked this pull request as ready for review July 6, 2024 00:27
@rmlibre rmlibre merged commit 26e0026 into main Jul 6, 2024
15 checks passed
rmlibre added a commit that referenced this pull request Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working notice attention is advised, discussion is welcome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant