Commit Graph

8 Commits

Author SHA1 Message Date
Brad Solomon
ddb47deb27 Allow Union[unicode, str] rather than just str in several places (#3887)
* Allow unicode objects throughout urlparse.py

Functions such as `urlparse()`, if given a unicode object,
will happily return a ParseResult of unicode components.

Relatedly, functions like `unquote()` will accept any of
bytes/str/unicode and return an object of the same type
or a composite containing that type.

* Allow unicode in several places in Thread

`name` and `kwargs` to Thread.__init__ function perfectly
well with unicode, not just str.

Note: the .name attribute will always be str even
if the constructor is passed something else, since
__init__ calls:

    self.__name = str(name or _newname())

* Use typing.AnyStr properly

...rather than defining a new TypeVar unncessarily.

* Use typing.Text properly

Text is behaviorally equivalent to Union[str, unicode]
for Python 2 argument types.

* Remove outdated import & definition

* [check file consistent] copy changes to _dummy_threading.pyi
2020-05-27 19:52:14 -07:00
Sebastian Rittau
87d7dd3d95 Fix annotations with literal values (#3411) 2019-10-28 06:59:28 -07:00
Sebastian Rittau
ec7960a8cb Convert namedtuples to class syntax (#3321) 2019-10-20 10:37:33 +02:00
Russ Allbery
f0ccb325aa Mark some urllib.parse return fields optional (#3332)
Per the urllib.parse documentation, username, password, hostname,
and port will be set to None if not set in the parsed URL.  The
same is true for urlparse in Python 2 according to its documentation.
2019-10-09 19:38:59 +02:00
Michael Lee
efb67946f8 Use variable annotations everywhere (#2909) 2019-04-13 10:40:52 +02:00
Jelle Zijlstra
9947c9d513 urlparse: allow unicode arguments in more places (#1451)
* urlparse: allow unicode arguments in more places

Part of #1411

urlunsplit() and similar functions accept either unicode or str in all
places. Their actual return type is unicode if any of the arguments is
unicode and nonempty, which the type system can't exactly express. I
left the return type as str because str is implicitly promoted to
unicode, so using the return type in a place that accepts unicode should
work.

unquote, parse_qs, and parse_qsl return unicode if you pass them unicode,
so AnyStr is appropriate in their stubs.

* fix type for urldefrag

The return type was wrong; this function returns a 2-tuple. The second member of the tuple is always a `str` if the argument type does not contain '#', and otherwise matches the type of the argument.
2017-07-04 19:20:23 -07:00
Lukasz Langa
6b5c6626d6 Fixing flake8 E121, E122, E123, E124, E125, E126 errors 2016-12-19 23:53:19 -08:00
Guido van Rossum
cb97bb54c0 Move 2.7 to 2 (#635)
Closes #579.
2016-10-26 16:24:49 -07:00