Skip to content

[WIP] docs: use sphinx-autodoc-typehints, minor typing improvements#6665

Closed
blueyed wants to merge 3 commits intopytest-dev:masterfrom
blueyed:doc-sphinx-autodoc-typehint
Closed

[WIP] docs: use sphinx-autodoc-typehints, minor typing improvements#6665
blueyed wants to merge 3 commits intopytest-dev:masterfrom
blueyed:doc-sphinx-autodoc-typehint

Conversation

@blueyed
Copy link
Contributor

@blueyed blueyed commented Feb 3, 2020


@contextmanager
def _runtest_for_main(self, item, when):
def _runtest_for_main(self, item, when: str) -> Generator[None, None, None]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bluetech
item not typed because of catch_log_handler{,s} being set/unset there.
Ignoring any refactors I've wondered if a ItemWithLogging type would make sense in general, which would have that attribute allowed then? (I do not think it is worth it, was just wondering)

Copy link
Member

Choose a reason for hiding this comment

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

Might work, but because the attribute is added and deleted, it can't be entirely correct, and would require casts as well, so probably doesn't make sense.

As for refactor, seems like a good case for an "item-level storage" mechanism #3740. Such storage could be typed in some appropriate manner, probably.

@blueyed blueyed force-pushed the doc-sphinx-autodoc-typehint branch from 21c1987 to 0a8e8d3 Compare February 3, 2020 10:22
@blueyed
Copy link
Contributor Author

blueyed commented Feb 3, 2020

Appears to not being able to handle the circular imports:

WARNING: Cannot resolve forward reference in type annotations of "_pytest.outcomes.fail": name 'NoReturn' is not defined
…
WARNING: Cannot resolve forward reference in type annotations of "_pytest.nodes.Node": name 'Session' is not defined

(With and without set_type_checking_flag)

@blueyed blueyed changed the title docs: use sphinx-autodoc-typehints, minor typing improvements [WIP] docs: use sphinx-autodoc-typehints, minor typing improvements Feb 3, 2020
blueyed added a commit to blueyed/pytest that referenced this pull request Feb 3, 2020
blueyed added a commit to blueyed/pytest that referenced this pull request Feb 3, 2020
Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

The type annotations LGTM.

I haven't looked into sphinx-autodoc-typehints, it sounds convenient though.

:type mark_list: List[Union[Mark, Markdecorator]]
:rtype: List[Mark]
"""
def normalize_mark_list(mark_list: List[Union[Mark, MarkDecorator]]) -> List[Mark]:
Copy link
Member

Choose a reason for hiding this comment

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

mark_list can be Iterable (if you feel like it)

@blueyed
Copy link
Contributor Author

blueyed commented Feb 9, 2020

@bluetech applied your suggestions in #6699.

@blueyed blueyed closed this Feb 9, 2020
@blueyed blueyed deleted the doc-sphinx-autodoc-typehint branch February 9, 2020 08:42
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