Add py.typed file

This commit is contained in:
Nikolaus Waxweiler 2020-09-16 12:03:52 +01:00
parent e1c9710272
commit 863d9fd3c8
4 changed files with 12 additions and 18 deletions

View File

@ -62,7 +62,7 @@ _date_parser = re.compile(
r"(?::(?P<minute>\d\d)"
r"(?::(?P<second>\d\d))"
r"?)?)?)?)?Z",
re.ASCII
re.ASCII,
)
@ -162,7 +162,7 @@ PlistEncodable = Union[
class PlistTarget:
""" Event handler using the ElementTree Target API that can be
"""Event handler using the ElementTree Target API that can be
passed to a XMLParser to produce property list objects from XML.
It is based on the CPython plistlib module's _PlistParser class,
but does not use the expat parser.
@ -407,8 +407,7 @@ def _string_or_data_element(raw_bytes: bytes, ctx: SimpleNamespace) -> etree.Ele
string = raw_bytes.decode(encoding="ascii", errors="strict")
except UnicodeDecodeError:
raise ValueError(
"invalid non-ASCII bytes; use unicode string instead: %r"
% raw_bytes
"invalid non-ASCII bytes; use unicode string instead: %r" % raw_bytes
)
return _string_element(string, ctx)
@ -539,12 +538,8 @@ def load(
"""
if not hasattr(fp, "read"):
raise AttributeError(
"'%s' object has no attribute 'read'" % type(fp).__name__
)
target = PlistTarget(
use_builtin_types=use_builtin_types, dict_type=dict_type
)
raise AttributeError("'%s' object has no attribute 'read'" % type(fp).__name__)
target = PlistTarget(use_builtin_types=use_builtin_types, dict_type=dict_type)
parser = etree.XMLParser(target=target)
result = etree.parse(fp, parser=parser)
# lxml returns the target object directly, while ElementTree wraps
@ -611,9 +606,7 @@ def dump(
"""
if not hasattr(fp, "write"):
raise AttributeError(
"'%s' object has no attribute 'write'" % type(fp).__name__
)
raise AttributeError("'%s' object has no attribute 'write'" % type(fp).__name__)
root = etree.Element("plist", version="1.0")
el = totree(
value,
@ -632,9 +625,7 @@ def dump(
else:
header = XML_DECLARATION + PLIST_DOCTYPE
fp.write(header)
tree.write(
fp, encoding="utf-8", pretty_print=pretty_print, xml_declaration=False
)
tree.write(fp, encoding="utf-8", pretty_print=pretty_print, xml_declaration=False)
def dumps(

View File

View File

@ -13,6 +13,8 @@ include *requirements.txt
include tox.ini
include run-tests.sh
recursive-include Lib/fontTools py.typed
include .appveyor.yml
include .codecov.yml
include .coveragerc

View File

@ -452,6 +452,7 @@ setup_params = dict(
packages=find_packages("Lib"),
include_package_data=True,
data_files=find_data_files(),
zip_safe=False, # So mypy can find typing information.
ext_modules=ext_modules,
setup_requires=setup_requires,
extras_require=extras_require,