Commit Graph

52 Commits

Author SHA1 Message Date
Sebastian Rittau
fe69ffcb0f Add a few missing stdlib modules (#4550) 2020-09-18 11:28:25 -04:00
Yuri Khan
87b758b0da Relax type of xml.etree.ElementTree.XMLParser target argument (#4538)
The target argument can be an arbitrary object.
If it has certain methods, they are used by XMLParser,
missing methods are ignored.

Ideally, we'd be able to type the potentially missing
methods correctly, but currently the type system is
unable to do so.

Fixes #4537
2020-09-14 12:50:12 +02:00
Shantanu
ad5bc751f3 xml.etree.ElementTree: mark some removals (#4496)
Co-authored-by: hauntsaninja <>
2020-08-30 06:41:50 -07:00
Jelle Zijlstra
5f9fd3d127 upgrade black version (#4486)
Manually removed a number of trailing commas to prevent black from unnecessarily
exploding some collections.
2020-08-26 18:36:01 +02:00
Eric Traut
baaffed1ac Added missing type annotations in various stdlib stubs. (#4402)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2020-08-06 18:27:21 -07:00
Eric Traut
04c74640f0 Removed imported symbols that are not accessed or re-exported (#4387)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2020-08-05 22:49:17 -07:00
Jelle Zijlstra
0142a87da8 adjust isort config (#4290)
Fixes #4288.

- Default imports to THIRD_PARTY, so in effect we merge the FIRST_PARTY and THIRD_PARTY stubs. This means import order is no longer affected by whether typing_extensions is installed locally.
- Treat typing_extensions, _typeshed and some others as standard library modules.

Note that isort master is very different from the latest release; we'll have to do something
different if and when the next isort release comes out.
2020-06-29 00:00:21 -07: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
Sebastian Rittau
51cf2f51b8 Add IO protocols to _typeshed (#4230) 2020-06-14 20:44:48 +02:00
Jelle Zijlstra
f67ea2031a xml.etree: use _typeshed (#4221) 2020-06-11 12:41:57 -07:00
Jelle Zijlstra
44a852dff5 Literal: always import from typing_extensions for simplicity (#4219) 2020-06-10 21:23:58 -07:00
Zhiming Wang
edb7dc1171 xml.etree.ElementTree: add support for os.PathLike for py36+ (#4097)
xml.etree.ElementTree uses open on filenames (e.g. [1]), so os.PathLike has
been supported as filenames since Python 3.6.

[1] 285ff63351/Lib/xml/etree/ElementTree.py (L584)
2020-05-27 10:04:12 +02:00
Shantanu
a94d6511fd xml.etree.ElementInclude: update include for py39 (#4086)
Co-authored-by: hauntsaninja <>
2020-05-26 17:39:36 -07:00
Rebecca Chen
53f4f68d71 saxutils.XMLGenerator should accept unicode encodings in Python 2. (#4031) 2020-05-17 18:05:21 -07:00
Diego Elio Pettenò
71804c38fc Add empty stubs for xml.dom.* modules. (#3856) 2020-03-27 09:13:37 +01:00
Jaromir Latal
d4c3ccbc16 [stdlib][xml] Initial typestubs for xml.dom (#3852) 2020-03-27 09:12:09 +01:00
Rune Tynan
7d8e2c8546 Add missing argument types for xml.sax stubs (#3706)
* Add missing argument types for xml.sax stubs

* Fix xml typings
2020-02-21 21:38:11 -08:00
Shantanu
655bca8450 xml.sax: make_parser accepts iterables in py38 (#3766)
https://bugs.python.org/issue34789
2020-02-21 20:28:47 -08:00
Anthony Sottile
e38b110f7b xml.sax.parse may also take IO[bytes] (#3725) 2020-02-05 20:56:57 +01:00
Shantanu
f96fe6abc0 xml.etree.ElementTree: update for py38 (#3700) 2020-02-01 09:23:11 -08:00
Shantanu
119547b931 xml: fix default values, mark positional-only args (#3675)
Note xml.etree.ElementTree.TreeBuilder.start has a default value for
attrs in the C-accelerated module.
2020-01-29 11:09:53 +01:00
Sebastian Rittau
0501e2b329 Annotations for remaining Python 3.8 additions (#3358)
* Add os.add_dll_directory()
* Add memfd_create() and flags
* Add type annotation to flags
* Add stat_result.st_reparse_tag and flags
* Add ncurses_version
* Add Path.link_to()
* Add Picker.reducer_override()
* Add plistlib.UID
* Add has_dualstack_ipv6() and create_server()
* Add shlex.join()
* Add SSL methods and fields
* Add Python 3.8 statistics functions and classes
* Remove obsolete sys.subversion
* Add sys.unraisablehook
* Add threading.excepthook
* Add get_native_id() and Thread.native_id
* Add Python 3.8 tkinter methods
* Add CLOCK_UPTIME_RAW
* Add SupportsIndex
* Add typing.get_origin() and get_args()
* Add unicodedata.is_normalized
* Add unittest.mock.AsyncMock

Currently this is just an alias for Any like Mock and MagicMock. All of
these classes should probably be sub-classing Any and add their own
methods. See also #3224.

* Add unittest cleanup methods
* Add IsolatedAsyncioTestCase
* Add ElementTree.canonicalize() and C14NWriterTarget
* cProfile.Profile can be used as a context manager
* Add asyncio task name handling
* mmap.flush() now always returns None
* Add posonlyargcount to CodeType
2019-10-14 09:53:48 +02:00
Sebastian Rittau
6507875f28 Annotate Python 3.8 removals (#3359)
* macpath
* time.clock()
* Some cgi functions
* XMLParser(html) and doctype()
* unicode_internal
* Two sqlite3 classes hidden
* fileinput bufsize arg
* Treeview.selection no longer takes arguments
2019-10-14 09:51:39 +02:00
Guido van Rossum
b336182b69 Fix some errors with --disallow-any-generics (#3276)
See #3267. Covers all of stdlib/2and3.
2019-09-29 09:15:27 -07:00
Sebastian Rittau
628eee29f7 Use Literal in a few more places (#3176) 2019-08-10 13:08:18 -07:00
Michael R. Shannon
568f1ea555 Add attributes to xml.etree.ElementTree.ParseError. (#3158) 2019-07-30 08:48:28 +02:00
Ran Benita
c9f9530224 xml.etree.ElementTree: use literal type for a more precise return value for tostring() (#3120) 2019-07-25 09:31:12 +02:00
Ran Benita
c66699800e xml.etree.ElementTree: fix missing None in get(), findtext() return type (#3093) 2019-07-01 14:28:40 +02:00
Michael Lee
efb67946f8 Use variable annotations everywhere (#2909) 2019-04-13 10:40:52 +02:00
Michael R. Shannon
a2ecfafa98 Add missing explicit Optional to stubs for the xml.etree package. (#2734)
Fixes #2733
2019-01-17 13:50:37 +01:00
Sebastian Rittau
ece96777a7 Re-export pyexpat instead of using check_consistency (#2649) 2018-11-29 07:29:59 -08:00
Maarten ter Huurne
eaae246062 Change argument type for xml.etree.ElementTree.iselement() to object (#2642)
It should be possible to ask for every object whether it looks like
an element. If only Elements are accepted, this function would always
return True.

Fixes #2629
2018-11-28 02:34:27 +01:00
Sebastian Rittau
006a79220f Flake8 fixes (#2549)
* Fix over-indented continuation lines

* Fix under-indented continuation lines

* Fix whitespace around default operator problems

* Limit line lengths

* Fix inconsistent files
2018-10-24 07:20:53 -07:00
Michael R. Crusoe
2e0af18dda slices of MutableSequences are also MutableSequences (#2428) 2018-09-25 13:06:59 -07:00
Martin DeMello
0c9f0d21d2 allow for unicode entity dicts in saxutils (#2345) 2018-07-24 11:18:23 -07:00
Yusuke Miyazaki
6192cce9d9 Avoid using string literals in type annotations (#2294) 2018-07-02 20:23:29 -07:00
Sebastian Rittau
7ebd609643 Add pyexpat and xml.parsers (#2276) 2018-06-28 10:26:17 -07:00
rchen152
38dc8f5a6a Switch usages of mypy_extensions.NoReturn over to typing.NoReturn. (#1942)
* Change mypy_extensions.NoReturn to typing.NoReturn everywhere.
2018-03-05 12:42:29 -08:00
Roy Williams
a618ee30d4 Fix instantiating a xml.etree.ElementTree.Element (#1930)
The methods removed by https://github.com/python/typeshed/pull/1816
are abstract in `MutableSequence` and therefore must be specified on `Element`.
2018-02-27 14:59:11 -08:00
rchen152
db6e2a637b Fix some bugs in xml.etree.ElementTree.Element's container behavior. (#1816)
* Have Element inherit from MutableSequence, which is more precise than Sequence.
* Remove unnecessary inherited methods (e.g., __getitem__).
* Correct extend() to take an Iterable. (Sequence was too specific.)
* Alphabetize the typing imports, for sanity.
2018-01-04 19:04:46 -08:00
Sally
37f1bf54a5 Fix type of source for xml.sax.parse (#1666)
Fixes https://github.com/python/typeshed/issues/1655
2017-10-25 09:45:48 -07:00
Gábor Bernát
f1a01b3017 [XML] iterparse is None for end-ns, Tuple[str, str] for start-ns, Element otherwise (#1520) 2017-10-04 08:24:27 -07:00
Jelle Zijlstra
fee2eaae30 xml.sax.saxutils: make some functions take AnyStr (#1457)
Fixes #1062
2017-07-04 19:18:43 -07:00
Matěj Cepl
367743adf0 Python 3 adds short_empty_elements attribute to xml.sax.saxutils.XMLGenerator. (#1265)
Fix #1265
2017-05-25 08:53:01 -07:00
Emily Morehouse
efec7d67e8 Removed SAX classes from xml/__init__.pyi (#1299)
- Removed class definitions from `xml/__init__.pyi` as they were merely outdated duplicates of the definitions from the correct file (`xml/sax/__init__.pyi`)
- Left file intact as it is necessary for the module
2017-05-22 16:08:08 -07:00
Emily Morehouse
b6d08b81a3 #1286 Remove header comments from stubs (#1292)
- Updates documentation related to previously required comment headers.
- Removes all comment headers from stubs
- Occasionally included a header for stubs that were noted to be incomplete or contained todo's.
2017-05-22 15:14:15 -07:00
Jelle Zijlstra
8f1875b97b fixes to xml.sax (#1201) 2017-04-24 15:03:07 -07:00
lincolnq
59789b8a3e Improve types for xml.etree.ElementTree (#930)
* Improve types for xml.etree.ElementTree

Update signatures to reflect the following peculiarities of the
ElementTree library:

- The elementtree library accepts unicode or bytes for most xml values
  in python2, and coerces everywhere -- but in python3, only str makes
  sense.
- In python 2, the library produces str or unicode instances
  unpredictably, depending on whether the xml is decodeable as ascii or
  not. In python 3, it always produces str instances.
- The parser functions accept unicode or bytes in 2 and 3 -- again, will
  coerce individual instances so heterogeneous lists are ok.
- In python 3, the tostring functions produce bytes or str, depending on
  the value of the 'encoding' parameter.

* improve docs
* Improve ElementFactory type by specifying dict of 2nd arg
2017-02-22 20:43:09 -08:00
Valérian Rousset
fe15d91041 merge */xml/etree into 2and3/xml/etree (#899)
Fixes #287.
2017-01-30 13:19:28 -08:00
Lukasz Langa
5f416fae64 Add missing List imports. 2016-12-21 01:06:52 -08:00