-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Include exceptions.pyi and fields.pyi #1937
Conversation
@sethmlarson I'm a little concerned we might have been trying to do too much with the previous PR. I created this one in light of the objective of moving as all the Steps 1 and 2 are captured in the commit f1fd1c0 (ports from |
@@ -0,0 +1,55 @@ | |||
from typing import Any, Optional, Union, Tuple, TYPE_CHECKING |
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.
From typeshed
at exceptions.pyi.
src/urllib3/fields.pyi
Outdated
@@ -0,0 +1,26 @@ | |||
# Stubs for requests.packages.urllib3.fields (Python 3.4) | |||
|
|||
from typing import Any, Callable, Dict, Optional |
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.
From typeshed
at fields.pyi.
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.
Couple of comments
from typing import Any, Callable, Dict, Optional | ||
|
||
def guess_content_type(filename: str, default: str) -> str: ... | ||
def format_header_param(name: str, value: str) -> str: ... |
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're missing types for format_header_param_rfc2231
and format_header_param_html5
, shouldn't Mypy catch that issue though?
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.
@sethmlarson Annoyingly with stub files, mypy only catches errors on a subsequent import. For example https://github.com/savarin/urllib3/compare/port-types-03...savarin:port-types-03-example?expand=1 would raise the following error.
src/urllib3/result.py:4: error: Argument 2 to "format_header_param" has incompatible type "int"; expected "str".
Types added for those two.
src/urllib3/fields.pyi
Outdated
name: str, | ||
data: Any, | ||
filename: Optional[str], | ||
headers: Optional[Dict[str, str]], |
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.
headers: Optional[Mapping[str, str]]
@sethmlarson Changes incorporated. I also have an idea on tracking progress. We can simply count the lines returned by
|
Codecov Report
@@ Coverage Diff @@
## master #1937 +/- ##
==========================================
+ Coverage 99.72% 99.81% +0.09%
==========================================
Files 24 24
Lines 2179 2179
==========================================
+ Hits 2173 2175 +2
+ Misses 6 4 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Hey @savarin wanted to thank you for all this work. Want to keep you up to date with what we're planning and how that relates to type hints. Right now I'm planning on shipping type hint support in v2 which likely won't be released until mid/late 2021. For now you can continue with type stubs and when the
|
@sethmlarson Thanks for sharing and the kind words. Re: plans, it's not a problem. Focus on 3.6+ types makes a lot of sense. Let me know if you have any further thoughts/comments on this PR. |
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.
LGTM
Addresses #1897, as an alternative to #1931.
The previous PR #1931 was created to incrementally add
.pyi
files fromtypeshed
, with the following steps:.pyi
files incrementally based on dep tree.pyi
files in fromtypeshed
as isnox -s lint
.pyi
files createdThis PR is created to illustrate another possibility, where the focus would be on porting as much of the
.pyi
files fromtypeshed
first. This involves only steps 1 - 3, i.e. changes made only where errors are raised.After all the
.pyi
files have been ported fromtypeshed
, step 4 would then be completed for all the.pyi
files.