Skip to content

Commit

Permalink
revert default parser, add FutureWarning (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 authored May 25, 2022
1 parent 10de4c9 commit fbbf567
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/ome_types/_convenience.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from pathlib import Path
from typing import Any, Dict, Optional, Union, cast
from warnings import warn

from typing_extensions import Protocol

Expand All @@ -18,7 +19,7 @@ def __call__(
def to_dict(
xml: Union[Path, str, bytes],
*,
parser: Union[Parser, str] = "lxml",
parser: Union[Parser, str, None] = None,
validate: Optional[bool] = None,
) -> Dict[str, Any]:
"""Convert OME XML to dict.
Expand All @@ -45,6 +46,17 @@ def to_dict(
KeyError
If `parser` is a string, and not one of `'lxml'` or `'xmlschema'`
"""
if parser is None:
warn(
"The default XML parser will be changing from 'xmlschema' to 'lxml' in "
"version 0.4.0. To silence this warning, please provide the `parser` "
"argument, specifying either 'lxml' (to opt into the new behavior), or"
"'xmlschema' (to retain the old behavior).",
FutureWarning,
stacklevel=2,
)
parser = "xmlschema"

if isinstance(parser, str):
if parser == "lxml":
from ._lxml import lxml2dict
Expand All @@ -67,7 +79,7 @@ def to_dict(
def from_xml(
xml: Union[Path, str, bytes],
*,
parser: Union[Parser, str] = "lxml",
parser: Union[Parser, str, None] = None,
validate: Optional[bool] = None,
) -> OME:
"""Generate OME metadata object from XML string or path.
Expand Down Expand Up @@ -97,7 +109,7 @@ def from_xml(
def from_tiff(
path: Union[Path, str],
*,
parser: Union[Parser, str] = "lxml",
parser: Union[Parser, str, None] = None,
validate: Optional[bool] = True,
) -> OME:
"""Generate OME metadata object from OME-TIFF path.
Expand Down

0 comments on commit fbbf567

Please sign in to comment.