Page MenuHome

Fix some of mypy errors in looper
ClosedPublic

Authored by Anna Sirota (railla) on Mar 10 2021, 12:42 PM.

Details

Summary

This is an attempt at salvaging mypy annotations that already exist in the standalone looper's code.

This doesn't make the updated looper code mypy-error-free yet (there are 166 errors even with tests and migrations excluded from the checks), but it makes it easier to salvage more code from the standalone looper later (and it's easier than actually fixing all of the existing mypy errors =/ )

(The tests are passing and payment flows/My Account don't appear to be affected by this patch)

Diff Detail

Event Timeline

Anna Sirota (railla) requested review of this revision.Mar 10 2021, 12:42 PM
Anna Sirota (railla) created this revision.
Anna Sirota (railla) edited the summary of this revision. (Show Details)

In some cases you annotate with object, in other cases with Any. What is the semantic difference between the two? If there is none, pick one (personally I prefer Any) and stick with it.

In some cases you annotate with object, in other cases with Any. What is the semantic difference between the two? If there is none, pick one (personally I prefer Any) and stick with it.

The semantic difference between the two is that Any is an escape from static typing, because it makes mypy skip any checks having to do with it, and object is an indication that this method/function must work with any kind of an object, so it semantically more suitable for overloading builtin methods, for example. They are not the same.

That said, I honestly don't care about this difference, what I do care about is keeping this code as it is right now, because it makes it easier for me to salvage patches from Sem's version of looper.

  • Use Any everywhere instead of object

The semantic difference between the two is that Any is an escape from static typing, because it makes mypy skip any checks having to do with it, and object is an indication that this method/function must work with any kind of an object, so it semantically more suitable for overloading builtin methods, for example. They are not the same.

Interesting, I've never looked it that way. In that case, objectify everything! :)

https://mypy.readthedocs.io/en/stable/command_line.html#disallow-dynamic-typing also shows some ways to get rid of Any, further strengthening your argument.

That said, I honestly don't care about this difference, what I do care about is keeping this code as it is right now, because it makes it easier for me to salvage patches from Sem's version of looper.

No need to further change this patch. I just wanted to express (with "objectify everything!") my support for using more object and less Any in type annotations.

This revision is now accepted and ready to land.Mar 15 2021, 5:18 PM