Skip to content

Conversation

@bluetech
Copy link
Member

Extracted from #6717.

_S = TypeVar("_S")


NOTSET = object()
Copy link
Member Author

Choose a reason for hiding this comment

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

object() doesn't produce a singleton on the type level, so I had to switch it to an idiom that does.

if isinstance(marks, MarkDecorator):
marks = (marks,)
else:
assert isinstance(marks, (tuple, list, set))
Copy link
Member Author

Choose a reason for hiding this comment

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

Generalized this a bit, otherwise type annotation is very ugly.

Copy link
Member Author

Choose a reason for hiding this comment

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

But turns out py3.5 doesn't have collections.abc.Collection, so I changed the runtime check to collections.abc.Sequence | set, but left the type as Collection. So there will be a slight mismatch until we can drop py3.5.

@bluetech bluetech force-pushed the parameterset-annotate branch from 8e90a10 to 4bfcf62 Compare February 13, 2020 17:04
@bluetech bluetech changed the title Type annotate ParameterSet Type annotate ParameterSet & param() Feb 13, 2020
if isinstance(marks, MarkDecorator):
marks = (marks,)
else:
assert isinstance(marks, (tuple, list, set))
Copy link
Member Author

Choose a reason for hiding this comment

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

But turns out py3.5 doesn't have collections.abc.Collection, so I changed the runtime check to collections.abc.Sequence | set, but left the type as Collection. So there will be a slight mismatch until we can drop py3.5.

__all__ = ["Mark", "MarkDecorator", "MarkGenerator", "get_empty_parameterset_mark"]


def param(*values, **kw):
Copy link
Member Author

Choose a reason for hiding this comment

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

I expanded the kwargs so I can annotate them and so that the types show up in the docs.

@bluetech bluetech closed this Feb 28, 2020
@bluetech bluetech deleted the parameterset-annotate branch February 28, 2020 12:08
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.

1 participant