You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 2, 2024. It is now read-only.
Subscripting the built-in types directly (e.g., list[int]) would result in a syntax error like TypeError: 'type' object is not subscriptable. This is unfortunate because Tutor thoroughly annotates all types, including nested data structures, which are harder to read when using the type names from typing.
Tutor supports all non-end-of-life (EOL) Python versions. Since Python 3.6 is EOL, we can start using Python 3.7 features. Of course, we will need to retain Python 3.7 compatibility until Jun 2023 and Python 3.8 compatibility until Oct 2024, so the from __future__ import annotations line will need to stick around until then.
Acceptance Criteria
Throughout the entire Tutor codebase:
Add from __future__ import annotations to the top of every module, right below the module's docstring.
Replace any usages of t.List, t.Dict, t.Set, t.Tuple, and t.Type with their built-in equivalents: list, dict, set, tuple, and type.
Ensure that make test still passes under Python 3.7, 3.8 and 3.9.
The text was updated successfully, but these errors were encountered:
tests/helpers.py has a function called run. It takes in an optional parameter and optionally returns using t.Optional[T].
In Python<=3.10, there is no substitute for t.Optional[T].
In 3.10+ we can change it to T|None , but we're not there yet
Context
Before Python 3.7, in order to fully annotate collections (lists, dicts, tuples), one had to import the type names from the
typing
module:Subscripting the built-in types directly (e.g.,
list[int]
) would result in a syntax error likeTypeError: 'type' object is not subscriptable
. This is unfortunate because Tutor thoroughly annotates all types, including nested data structures, which are harder to read when using the type names fromtyping
.After Python 3.7, though, the built-in collection types can be used directly:
Tutor supports all non-end-of-life (EOL) Python versions. Since Python 3.6 is EOL, we can start using Python 3.7 features. Of course, we will need to retain Python 3.7 compatibility until Jun 2023 and Python 3.8 compatibility until Oct 2024, so the
from __future__ import annotations
line will need to stick around until then.Acceptance Criteria
Throughout the entire Tutor codebase:
from __future__ import annotations
to the top of every module, right below the module's docstring.t.List
,t.Dict
,t.Set
,t.Tuple
, andt.Type
with their built-in equivalents:list
,dict
,set
,tuple
, andtype
.make test
still passes under Python 3.7, 3.8 and 3.9.The text was updated successfully, but these errors were encountered: