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

Remove STUserDict #191

Conversation

WilliamJamieson
Copy link
Collaborator

@WilliamJamieson WilliamJamieson commented May 30, 2023

STUserDict is essentially a copy of the Python standard library's collections.UserDict source code with the change of name and the change of the data (UserDict) variable to _data (STUserDict). This copy was a little while ago and is no longer "in-sync" with the standard library's version.

It turns out that this approach is a bit "overkill" for what DNode (what uses STUserDict) actually needs. Instead it just needs to be an abstract mutable mapping (abc.MutableMapping).

This PR switches DNode from using STUserDict to abc.MutableMapping which solves this issue. It also removes STUserDict because it is no-longer necessary.

Checklist

@WilliamJamieson
Copy link
Collaborator Author

Leaving this as a draft until all the regression tests are functional again. This will need to be carefully tested.

@codecov
Copy link

codecov bot commented May 30, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.10 ⚠️

Comparison is base (7056f21) 97.93% compared to head (0dac8ab) 97.84%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #191      +/-   ##
==========================================
- Coverage   97.93%   97.84%   -0.10%     
==========================================
  Files           9        8       -1     
  Lines        1258     1204      -54     
==========================================
- Hits         1232     1178      -54     
  Misses         26       26              
Impacted Files Coverage Δ
tests/test_stnode.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines -29 to -41
def find_mod_objs_patched(*args, **kwargs):
from sphinx_automodapi.utils import find_mod_objs

return find_mod_objs(args[0], onlylocals=True)


def patch_automodapi(app):
"""Monkey-patch the automodapi extension to exclude imported members"""
from sphinx_automodapi import automodsumm

automodsumm.find_mod_objs = find_mod_objs_patched


Copy link
Collaborator Author

@WilliamJamieson WilliamJamieson May 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Monkey patches like this are generally a bad idea. The whole reason for the need of this patch was poor construction of stuserdict.py module to begin with. #156 (comment) details a couple of different ways of properly resolving this without monkey patching. However, all of those options are moot because this PR removes stuserdict.py, which side steps the issue completely.

@WilliamJamieson WilliamJamieson force-pushed the refactor/remove_stuserdict branch from 0694c53 to 3962d7c Compare June 2, 2023 00:38
@WilliamJamieson
Copy link
Collaborator Author

The regression tests passed: https://plwishmaster.stsci.edu:8081/job/RT/job/Roman-devdeps/298/ so this is ready.

@WilliamJamieson WilliamJamieson marked this pull request as ready for review June 2, 2023 00:58
@WilliamJamieson WilliamJamieson requested a review from a team as a code owner June 2, 2023 00:58
Copy link
Collaborator

@PaulHuwe PaulHuwe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@WilliamJamieson WilliamJamieson force-pushed the refactor/remove_stuserdict branch 2 times, most recently from 85b1346 to 0bf3808 Compare June 6, 2023 17:52
These are important to demonstrate the copy behavior does not change when we remove STUserDict
We imply these stnode based objects should be self copyable, so this makes them self copyable.
It is no longer being used.
@WilliamJamieson WilliamJamieson force-pushed the refactor/remove_stuserdict branch from 0bf3808 to 0dac8ab Compare June 6, 2023 19:40
@WilliamJamieson WilliamJamieson merged commit 4a8f808 into spacetelescope:main Jun 6, 2023
@WilliamJamieson WilliamJamieson deleted the refactor/remove_stuserdict branch June 6, 2023 19:59
mairanteodoro pushed a commit to mairanteodoro/roman_datamodels that referenced this pull request Jun 8, 2023
This was referenced Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants