-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
PEP 484/Mypy type annotations? #114
Comments
Hey, this would be awesome! I've been meaning to get these added to the codebase for a while now. Agree with the preference for the most modern syntax. Worth noting that while the codebase supports python 2 at the moment, I've been planning to bite the bullet, stop supporting it, clean up the codebase, and take advantage of some 3-only features like dataclasses and natively ordered dictionaries. So don't worry about supporting old versions. Excited to see how the code looks with annotations added! |
Question barrage incoming. I've been able to narrow down the type errors over on my branch [linked], but I'm unable to figure out the following:
|
Cheers for raising all these issues, lots of room for improvement here. Things are a bit hectic for me over the next few days so won't have time to address all these issues immediately, but a few quick ones:
|
update: I'm currently stuck working adding type annotations to the stuff that reqires sqlalchemy internals. Turns out typeshed does not include sqlalchemy stubs. Instead, there are potentially-usable stubs at https://github.com/dropbox/sqlalchemy-stubs, which is in alpha. Once again, I should have time to make progress this weekend. |
I managed to eliminate type errors within Also, I've hit a wall trying to type callbacks. I had to nuke the great metaprogramming in # clear pseudocode
class Callback(Protocol): # use a callback protocol as the method type
def __call__(self, specific: typed = defaulted, keyword: ars = defaulted) -> Statements: ...
def make_partial(name: Literal["schemas"]) -> Callback:
def callback(self: 'Changes', *args, **kwargs) -> Statements:
return statements_for_changes(getattr(self, name), *args, **kwargs)
class Changes():
schemas = make_partial("schemas") # should be a method with type Callback However, the |
Would you be interested in using mypy to validate PEP 484 type annotations as a part of
migra
's CI? If so, what syntax would you find acceptable? There's:.pyi
stub files, which can't be used to check themigra
codebase.I'd be willing to take this on over the weekend.
The text was updated successfully, but these errors were encountered: