Use type identifiers instead of string type hints

Use type identifiers instead of using string type hints.

Historically, string type annotations catered for the case where a function on line 5 returns an instance of a class that that is defined at line 7: how can type annotations on line 5 refer to a class that has not been defined yet?

Python 3.7 solved this problem by introducing postponing evaluation of type annotations until Python is ready to use them, removing the need to use string annotation styles.

Function annotations and variable annotations don't evaluate at function definition time. Instead, under the hood they are preserved in __annotations__ in string form.

This deferring allows forward references: type hints can contains names that have not been defined yet.

If our GitHub code review bot spots this issue in your pull request it gives this advice:

code-review-doctorbotsuggested changes just now
helpers.py
1
+
def foo_bar() -> "FooBarClass":

Use type identifiers instead of using string type hints.

Read more
Suggested changes
-
def foo_bar() -> "FooBarClass":
+
def foo_bar() -> FooBarClass:
Expand 4 lines ...
Commit suggestion
2
+
    return FooBarClass()
3
+
	
4
+
class FooBarClass:
5
+
    pass
Update helpers.py

Instantly check if you have this issue for free

    Works with tools you use

    Read about how it works.