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

docs build - fix for automodapi #156

Merged
merged 6 commits into from
Apr 24, 2023
Merged

Conversation

zacharyburnett
Copy link
Collaborator

@zacharyburnett zacharyburnett commented Apr 18, 2023

apply fix from #155 (comment) for docs build issue in Python > 3.8

@zacharyburnett zacharyburnett self-assigned this Apr 18, 2023
@zacharyburnett
Copy link
Collaborator Author

It looks like the build fails with
https://readthedocs.org/projects/roman-datamodels/builds/20154238/

TypeError: <lambda>() got an unexpected keyword argument 'onlylocals'

@codecov
Copy link

codecov bot commented Apr 18, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (5087ffe) 96.73% compared to head (b004f7a) 96.73%.

❗ Current head b004f7a differs from pull request most recent head 72bb963. Consider uploading reports for the commit 72bb963 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #156   +/-   ##
=======================================
  Coverage   96.73%   96.73%           
=======================================
  Files           9        9           
  Lines        1101     1101           
=======================================
  Hits         1065     1065           
  Misses         36       36           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

@nden
Copy link
Collaborator

nden commented Apr 24, 2023

It looks like the behavior has changed with Python 3.9. The issue and a proposed updated solution is documented here.

@zacharyburnett zacharyburnett changed the title monkey patch automodapi to exclude imported members docs build - monkey patch automodapi to exclude imported members Apr 24, 2023
@zacharyburnett zacharyburnett changed the title docs build - monkey patch automodapi to exclude imported members docs build - fix for automodapi Apr 24, 2023
@zacharyburnett zacharyburnett marked this pull request as ready for review April 24, 2023 13:16
@zacharyburnett zacharyburnett requested review from a team and WilliamJamieson as code owners April 24, 2023 13:16
Copy link
Collaborator

@ddavis-stsci ddavis-stsci left a comment

Choose a reason for hiding this comment

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

Looks OK to me, hopefully they will update the astropy/sphinx code so we can remove the patch at some point.

@nden
Copy link
Collaborator

nden commented Apr 24, 2023

The failure is unrelated.

@nden nden merged commit 52b5451 into spacetelescope:main Apr 24, 2023
@WilliamJamieson
Copy link
Collaborator

I do not like this fix considering its only needed to fix some type hints.

@nden
Copy link
Collaborator

nden commented Apr 24, 2023

@WilliamJamieson Do you have a better suggestion?

@zacharyburnett zacharyburnett deleted the automod_fix branch April 24, 2023 15:45
@WilliamJamieson
Copy link
Collaborator

Short answer is fix stuserdict.py, which is what is causing the issue. This can be done in several ways (note these are not mutually exclusive improvements):

  1. Define an __all__ = ["STUserDict"] in stuserdict.py. Per pep-8:

To better support introspection, modules should explicitly declare the names in their public API using the __all__ attribute. Setting __all__ to an empty list indicates that the module has no public API.

So __all__ should be defined anyways

  1. The issue is it attempting to generate documents for Any and Iterator which are used purely as type annotations. This is because they are imported as no private things in the namespace there. As they are purely type annotations changing:
    from typing import Any, Iterator
    to
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from typing import Any, Iterator
from typing import Any, Iterator

Allows for the type-hints to say, but they will only be imported if type checking via the annotations is used.

  1. Remove the type hints all together. No where else in roman_datamodels are there type hints.

The either options 1 and 2 or 1 and 3 would be the best way to deal with the issue.

Note, STUserDict seems redundant and should be removed. It is only a base class for stnode.DNode, which overloads much of its interface anyways. Moreover, STUserDict appears to be a copy-paste from the CPython standard library's UserDict (from 3.8/3.9) where .data has been replaced by ._data. Instead it would be simpler to simply have DNode subclass collections.abc.MutableMapping directly. However, this type of change is outside the scope of this bugfix.

WilliamJamieson added a commit to WilliamJamieson/roman_datamodels that referenced this pull request May 30, 2023
@WilliamJamieson WilliamJamieson mentioned this pull request May 30, 2023
4 tasks
WilliamJamieson added a commit to WilliamJamieson/roman_datamodels that referenced this pull request Jun 2, 2023
WilliamJamieson added a commit to WilliamJamieson/roman_datamodels that referenced this pull request Jun 5, 2023
WilliamJamieson added a commit to WilliamJamieson/roman_datamodels that referenced this pull request Jun 6, 2023
WilliamJamieson added a commit to WilliamJamieson/roman_datamodels that referenced this pull request Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants