You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the documentation it is possible to validate an ElementTree object against an XML schema using etree.XMLSchema.validate() method or using it as a callable. In both cases, mypy traces an error. E.g.:
importsysfromlxmlimportetreedefmain() ->None:
try:
schema_file=sys.argv[1]
file=sys.argv[2]
exceptIndexError:
sys.exit("Missing argument(s)")
schema=etree.XMLSchema(etree.parse(schema_file))
doc=etree.parse(file)
ifschema(doc):
print(f"{file} is valid")
else:
print(f"{file} is not valid")
ifschema.validate(doc):
print(f"{file} is valid")
else:
print(f"{file} is not valid")
if__name__=='__main__':
main()
% mypy main.py
main.py:16: error: "XMLSchema" not callable
main.py:21: error: "XMLSchema" has no attribute "validate"
The text was updated successfully, but these errors were encountered:
According to the documentation it is possible to validate an
ElementTree
object against an XML schema usingetree.XMLSchema.validate()
method or using it as a callable. In both cases, mypy traces an error. E.g.:The text was updated successfully, but these errors were encountered: