-
-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typing/models.readers #321
Typing/models.readers #321
Conversation
|
here are the remaining type errors in this file (
might need some help delving into these. they look they mostly from missing 'None' checks |
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 staticmethod or classmethod is good for this case, depending on the method sematic.
|
||
@classmethod | ||
def from_directory(cls, dir: Path) -> "Setup": | ||
return _SetupReader.read_from_directory(dir) |
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.
Why prefer exposing Setup
instead of SetupReader
? You know, it may involve changing the reference in other modules as well.
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.
because i'm now exposing a strongly-typed 'Setup' class instead of a stringly-typed dictionary.
I've updated both external modules that reference this
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.
these changes bring the number of mypy errors down from 44 to 20. Still a few to go though! - #321 (comment)
in the previous implementation the 'setup' is stored in a Dict[str, Any]
, which means type inference doesn't work in any function that indexes any of the fields.
Now I could still have imported the SetupReader
in other modules instead of Setup
, but i think this is a neater abstraction. the from_directory
static method on Setup
is effectively a constructor, and the calling code doesn't need to know anything about the SetupReader
, which is now effectively just a helper class
4dc823b
to
2118a32
Compare
3f68cdd
to
7f86f0d
Compare
rebased on master |
all the remaining type errors in this file are related to the
|
b0f9c91
to
2784aed
Compare
2784aed
to
875163c
Compare
rebased on master |
i've added decorators to ignore the typing errors in some of these functions. it's not an ideal solution, but it will suppress the errors and get you a step closer to using mypy in CI/pre-commit. seems like parsing |
Pull Request Check List
news/
describing what is new.Describe what you have changed in this PR.
refactor
models.readers
to improve typing support