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

py36+: use new NamedTuple syntax #7847

Closed
wants to merge 1 commit into from
Closed

py36+: use new NamedTuple syntax #7847

wants to merge 1 commit into from

Conversation

asottile
Copy link
Member

@asottile asottile commented Oct 3, 2020

See #7808

this one is slightly controversial, though I expect almost zero usage of 3.6.0

@bluetech
Copy link
Member

bluetech commented Oct 3, 2020

If it's just for this I think it's probably not worth the hassle of the "3.6 but not 3.6.0" subtlety? We did endure 3.5.{0,1} which were much worse than this...

@asottile
Copy link
Member Author

asottile commented Oct 3, 2020

If it's just for this I think it's probably not worth the hassle of the "3.6 but not 3.6.0" subtlety? We did endure 3.5.{0,1} which were much worse than this...

there's also NoReturn in 3.6.2 but yeah this is pretty subtle. for what it's worth pre-commit does 3.6.1+ and there hasn't been any complaints thus far

@nicoddemus
Copy link
Member

nicoddemus commented Oct 4, 2020

I see your point @asottile but I agree with @bluetech, I would prefer to avoid having to special case, and this case doesn't really buy us much.

However I think we can mark the code so it is clear that's only 3.6.0:

if sys.version_info[:3] == (3, 6, 0):
    # In 3.6.0 NamedTuples, ...
    class _ParameterSet(
        NamedTuple(
            "ParameterSet",
            [
                ("values", Sequence[Union[object, NotSetType]]),
                ("marks", Collection[Union["MarkDecorator", "Mark"]]),
                ("id", Optional[str]),
            ],
        )
    ):
    pass
else:    
    class _ParameterSet(NamedTuple):
        values: Sequence[Union[object, NotSetType]]
        marks: Collection[Union["MarkDecorator", "Mark"]]
        id: Optional[str]


class ParameterSet(_ParameterSet):
    ...

This helps finding the code when we drop 3.6.

@asottile asottile closed this Oct 4, 2020
@asottile asottile deleted the py36_namedtuple branch October 4, 2020 17:21
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.

3 participants