Commit Graph

15 Commits

Author SHA1 Message Date
Shantanu
6ff5b88ca7 typeshed: remove crufty comments (#4699)
Co-authored-by: hauntsaninja <>
2020-10-23 09:40:06 +02:00
Jelle Zijlstra
5d553c9584 apply black and isort (#4287)
* apply black and isort

* move some type ignores
2020-06-28 13:31:00 -07:00
Shantanu
009e650a1d string: various fixes (#3814) 2020-03-06 11:02:18 +01:00
Mohammed El-Afifi
c76a298ffa Fix type hints in Template class (#3491)
Nothing in the standard library documentation for the string module suggests that the value associated with any key in the mapping parameter(or kwds) to Template.substitute and Template.safe_substitute should be a string. In fact any object can be used, for example

Template("$number is a number.").substitute({"number": 1})

The above code sample currently causes an error message like this:

error: Dict entry 0 has incompatible type "str": "int"; expected "str": "str"

which obviously shouldn't be emitted. Also a similar logic is already in place for methods in the Formatter class. However as I saw the notice about loose types above the Formatter class, I opted to use `object` instead of `Any` as the implementation inside the affected functions just uses the built-in str function on values inside mappings.
2019-11-24 18:16:48 -08:00
Sebastian Rittau
de26a3d109 Remove raise statements from function bodies (#3355)
While it may eventually be useful to mark the exceptions that can be
raised from a function or method, the semantics are currently undefined
and unclear.
2019-10-13 21:51:43 +02:00
Sebastian Rittau
256b3ce8ab Remove a bunch of unused imports (#3323) 2019-10-08 07:59:32 -07:00
Michael Lee
efb67946f8 Use variable annotations everywhere (#2909) 2019-04-13 10:40:52 +02:00
Jelle Zijlstra
1d6e3f492e Fix incorrect usage of AnyStr (#1215)
* Fix incorrect usage of AnyStr

- sqlite3 was using Union[bytes, AnyStr], which doesn't make sense
- The urllib functions I changed accept either bytes or str for their "safe"
  argument
- Also added supports for PathLike to pstats
- Remove some unused imports of AnyStr

* pstats: python 2 accepts unicode
2017-04-27 08:47:59 -07:00
Semyon Proshev
c10dc797e7 Remove object as the only ancestor for string.Formatter in Python 3 stubs. (#1072) 2017-03-22 07:33:46 -07:00
Sebastian Meßmer
6ffaadbd67 Fix string.pyi (#971)
Add missing types for two arguments
2017-03-06 08:08:36 -08:00
Alvaro Caceres
ecc400f125 Make string.Template.substitute's arg optional (#535) 2016-09-12 11:12:28 -07:00
David Euresti
d760d48f52 Copy string.Formatter to python 3 (#443) 2016-08-05 07:47:23 -07:00
Matthias Kramm
94c9ce8fd0 Consistently use '= ...' for optional parameters. 2015-11-09 13:55:02 -08:00
Matthias Kramm
d2a3d4a4ed Use explicit "# type: str" instead of '' shortcut. 2015-11-09 07:59:24 -08:00
Matthias Kramm
337abed05a add (overwrite with) mypy stubs, if available 2015-09-30 09:59:44 -07:00