typing: move from comment type hints to Python 3.6 hints#34305
typing: move from comment type hints to Python 3.6 hints#34305
Conversation
|
Sigh. TIL about Python 3.6.15 (default, Dec 21 2021, 08:03:21)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.match("foo", "foo")
<_sre.SRE_Match object; span=(0, 3), match='foo'>Python 3.7.15 (default, Nov 15 2022, 10:33:03)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.match("foo", "foo")
<re.Match object; span=(0, 3), match='foo'>So you have to use |
|
Are we running the style tests on multiple versions of Python? I think we only need to test on the latest version. |
When you use the real type hints, things can fail in older versions even if we do not run the style checks. e.g.: import re
from typing import List, Tuple
def __init__(self, all_unquoted_flag_pairs: List[Tuple[re.Match, str]]):
...
import re
from typing import List, Match, Tuple
def __init__(self, all_unquoted_flag_pairs: List[Tuple[Match[str], str]]):
... |
We've stopped supporting Python 2, and contributors are noticing that our CI no longer allows Python 2.7 comment type hints. They end up having to adapt them, but this adds extra unrelated work to PRs. - [x] Move to 3.6 type hints across the entire code base
|
Gotcha. There's also: from __future__ import annotationsbut I've been avoiding that because of https://docs.python.org/3/library/__future__.html#id2. |
|
Sadly looks like we cannot have that until 3.7 |
…k#34305) We've stopped supporting Python 2, and contributors are noticing that our CI no longer allows Python 2.7 comment type hints. They end up having to adapt them, but this adds extra unrelated work to PRs. - [x] Move to 3.6 type hints across the entire code base
Apparently I forgot to do this in #34305.
Apparently I forgot to do this in #34305.
Apparently I forgot to do this in #34305.
Apparently I forgot to do this in spack#34305.
Apparently I forgot to do this in spack#34305.
…k#34305) We've stopped supporting Python 2, and contributors are noticing that our CI no longer allows Python 2.7 comment type hints. They end up having to adapt them, but this adds extra unrelated work to PRs. - [x] Move to 3.6 type hints across the entire code base
Apparently I forgot to do this in spack#34305.
Apparently I forgot to do this in spack#34305.
Apparently I forgot to do this in spack#34305.
We've stopped supporting Python 2, and contributors are noticing that our CI no longer allows Python 2.7 comment type hints. They end up having to adapt them, but this adds extra unrelated work to PRs.