-
-
Notifications
You must be signed in to change notification settings - Fork 458
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
Add py3.5 compatible stubs to objector.py #1173
Conversation
praw/objector.py
Outdated
from .exceptions import APIException, ClientException | ||
from .util import snake_case_keys | ||
from typing import Dict, List, Any, Union, Optional, NoReturn, TypeVar |
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.
Can you move system-level imports above package-level ones?
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.
ok
Thanks! 🎆 |
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 realize this has been merged already but I believe there's a mistake.
def check_error(cls, data): | ||
def check_error( | ||
cls, data: Union[List[Any], Dict[str, Dict[str, str]]] | ||
) -> NoReturn: |
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 believe usage of NoReturn
here is incorrect. Per the documentation:
Special type indicating that a function never returns.
The check_error
function sometimes never returns (when an exception is raised) but usually returns None
(when no exception is raised). Type annotations should be updated to reflect this. I'm not familiar with type annotations, but perhaps a Union[NoneType, NoReturn]
would be appropriate.
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 decided to just not use NoReturn so this should be phased out as well. I’m on a phone now so I’ll make a PR tomorrow.
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.
Good catch @jarhill0. To be honest, I haven't really scrutinized these PRs at all. I figure it's all an improvement, even if it's not 100% perfect.
Parent: #1164
Type hints: