-
Notifications
You must be signed in to change notification settings - Fork 1
More types #72
base: master
Are you sure you want to change the base?
More types #72
Conversation
This will show any untyped functions.
Ignore a deprecated class
This doesn't approach the Gpio or Servo constructors for now, but all the simpler functions are annotated.
This doesn't approach the all_known_boards attribute for now as it's not at all clear how to type that suitably.
robot/robot.py
Outdated
@@ -139,7 +139,7 @@ def _games(self) -> BoardList[GameState]: | |||
return self._update_boards(self.known_gamestates, GameState, 'game') | |||
|
|||
@staticmethod | |||
def _single_index(name, list_of_boards: BoardList[TBoard]) -> TBoard: | |||
def _single_index(name: Any, list_of_boards: BoardList[TBoard]) -> TBoard: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there something we can constrain it down to besides Any
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, that should, I think, be str
? Not sure why I made that Any
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I know why I made that Any
-- because that's the technically correct type. The only thing we do with the name is format it intio a string, so we don't care what type it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should still constrain it to a better type that reflects what it should be, even if the implementation doesn't actually care what type it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While 'Any' is technically correct, all our usages of it are going to be strings. Realistically any other type here is almost certainly an error.
This adds a bunch more types, though as a result we get more errors. I think some of the errors are fixable, though I'm not sure we can actually get to a point of having a clean type-check with some of the current structures. If things need changing, I'll probably do that in separate branches.
Depends on:
robot.robot.Robot
(not necessarily that PR specifically, but we need to do something and we know we want to tidy them up at some point)Simplify board lists #79: Simplify board lists (which greatly simplifies typingBoardList
)Collect the board lists only when needed #80: Collect board lists only when needed (I think that change will simplify the typing of that collection)