Skip to content

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Jan 13, 2020

No description provided.


def _prepareconfig(args=None, plugins=None):
def _prepareconfig(
args: Optional[Union[List, Tuple]] = None,
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this can also be a py.path.local. Even though it's not a real type yet, if you recall we decided to add it anyway so once typing is added to py.path it will start working.


def get_config(args=None, plugins=None):
def get_config(
args: Optional[Union[List, Tuple]] = None,
Copy link
Member

Choose a reason for hiding this comment

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

List and Tuple without a [] is equivalent to List[Any] and Tuple[Any]. Are there narrower types that can be used?

If yes, it's OK to leave them out for now, leaving them out indicates a TODO.

If no, I prefer to put explicit List[Any], this it's clear it can really be anything and is not just omitted/TODO.


def __init__(self, pluginmanager, *, invocation_params=None) -> None:
def __init__(
self, pluginmanager: "PytestPluginManager", *, invocation_params=None
Copy link
Member

Choose a reason for hiding this comment

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

Maybe invocation_params: Optional[Config.InvocationParams]?

(OK if you left it out intentionally).

@blueyed blueyed changed the base branch from features to master January 17, 2020 08:16
@blueyed blueyed closed this Jan 17, 2020
@blueyed blueyed reopened this Jan 17, 2020


def get_parametrized_fixture_keys(item, scopenum):
def get_parametrized_fixture_keys(
Copy link
Member

Choose a reason for hiding this comment

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

Depending on how much effort you're willing to expand on this function, it looks like this can be something like this:

@overload
def get_parametrized_fixture_keys(item: "nodes.Item", scopenum: Literal[0]) -> Iterator[Tuple[str, int]]: ...

@overload
def get_parametrized_fixture_keys(item: "nodes.Item", scopenum: Literal[1, 2]) -> Iterator[Tuple[str, int, py.path.local]]: ...

@overload
def get_parametrized_fixture_keys(item: "nodes.Item", scopenum: Literal[4]) -> Iterator[Tuple[str, int, py.path.local, "Class"]]: ...

Whether it needs scopenum: int fallback depends on the callers.

from typing import Type

_PluggyPlugin = object

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 since this might be used elsewhere - where should be put this?

Copy link
Member

Choose a reason for hiding this comment

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

As long is we keep it internal for now (I mean, not intended to be exposed in the "public" typing in the future), I guess putting it where PytestPluginManager is defined makes most sense?

A short comment here would be helpful, something like

A type to represent plugin objects. Plugins can be any namespace, so we can't narrow it down much, but we use an alias to make the intent clear. Ideally this type would be provided by pluggy itself.

BTW, I wouldn't put it under TYPE_CHECKING, this way we can use it without the annoying quotes.

Copy link
Contributor Author

@blueyed blueyed Jan 27, 2020

Choose a reason for hiding this comment

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

Thanks! Amended in a39b4e2 (#6580).

@bluetech
Copy link
Member

@blueyed Are you working on this PR?

@blueyed
Copy link
Contributor Author

blueyed commented Feb 28, 2020

@blueyed Are you working on this PR?

No. Some things have been taken out of it already, and I plan to revisit it to see if anything is left.

@blueyed
Copy link
Contributor Author

blueyed commented Feb 28, 2020

Closing for now.

@blueyed blueyed closed this Feb 28, 2020
@blueyed blueyed deleted the typing branch February 28, 2020 21:22
@blueyed
Copy link
Contributor Author

blueyed commented Feb 28, 2020

@bluetech
Feel free to pick anything from here, of course.

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