Skip to content

Commit

Permalink
Add type: ignore for fallback import
Browse files Browse the repository at this point in the history
This will only work in pydantic v2 with mypy but typing with
pydantic is already broken with v1 with the changes on this
branch.
  • Loading branch information
timj committed Jul 4, 2023
1 parent b7a44d6 commit 9851811
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/_quantum_backed.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
try:
from pydantic.v1 import BaseModel
except ModuleNotFoundError:
from pydantic import BaseModel
from pydantic import BaseModel # type: ignore

from ._butlerConfig import ButlerConfig
from ._deferredDatasetHandle import DeferredDatasetHandle
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/core/datasets/ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
try:
from pydantic.v1 import BaseModel, StrictStr, validator
except ModuleNotFoundError:
from pydantic import BaseModel, StrictStr, validator
from pydantic import BaseModel, StrictStr, validator # type: ignore

from ..configSupport import LookupKey
from ..dimensions import DataCoordinate, DimensionGraph, DimensionUniverse, SerializedDataCoordinate
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/core/datasets/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
try:
from pydantic.v1 import BaseModel, StrictBool, StrictStr
except ModuleNotFoundError:
from pydantic import BaseModel, StrictBool, StrictStr
from pydantic import BaseModel, StrictBool, StrictStr # type: ignore

from ..configSupport import LookupKey
from ..dimensions import DimensionGraph, SerializedDimensionGraph
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/core/datastoreCacheManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
try:
from pydantic.v1 import BaseModel, PrivateAttr
except ModuleNotFoundError:
from pydantic import BaseModel, PrivateAttr
from pydantic import BaseModel, PrivateAttr # type: ignore

from .config import ConfigSubset
from .configSupport import processLookupConfigs
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/core/datastoreRecordData.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
try:
from pydantic.v1 import BaseModel
except ModuleNotFoundError:
from pydantic import BaseModel
from pydantic import BaseModel # type: ignore

from .datasets import DatasetId
from .dimensions import DimensionUniverse
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/core/dimensions/_coordinate.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
try:
from pydantic.v1 import BaseModel
except ModuleNotFoundError:
from pydantic import BaseModel
from pydantic import BaseModel # type: ignore

from ..json import from_json_pydantic, to_json_pydantic
from ..named import NamedKeyDict, NamedKeyMapping, NamedValueAbstractSet, NameLookupMapping
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/core/dimensions/_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
try:
from pydantic.v1 import BaseModel
except ModuleNotFoundError:
from pydantic import BaseModel
from pydantic import BaseModel # type: ignore

from .._topology import TopologicalFamily, TopologicalSpace
from ..json import from_json_pydantic, to_json_pydantic
Expand Down
10 changes: 9 additions & 1 deletion python/lsst/daf/butler/core/dimensions/_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@
try:
from pydantic.v1 import BaseModel, Field, StrictBool, StrictFloat, StrictInt, StrictStr, create_model
except ModuleNotFoundError:
from pydantic import BaseModel, Field, StrictBool, StrictFloat, StrictInt, StrictStr, create_model
from pydantic import ( # type: ignore
BaseModel,
Field,
StrictBool,
StrictFloat,
StrictInt,
StrictStr,
create_model,
)

from ..json import from_json_pydantic, to_json_pydantic
from ..persistenceContext import PersistenceContextVars
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
try:
from pydantic.v1 import BaseModel, PrivateAttr
except ModuleNotFoundError:
from pydantic import BaseModel, PrivateAttr
from pydantic import BaseModel, PrivateAttr # type: ignore

_LONG_LOG_FORMAT = "{levelname} {asctime} {name} {filename}:{lineno} - {message}"
"""Default format for log records."""
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/core/quantum.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
try:
from pydantic.v1 import BaseModel
except ModuleNotFoundError:
from pydantic import BaseModel
from pydantic import BaseModel # type: ignore

from .datasets import DatasetRef, DatasetType, SerializedDatasetRef, SerializedDatasetType
from .datastoreRecordData import DatastoreRecordData, SerializedDatastoreRecordData
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/core/serverModels.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
try:
from pydantic.v1 import BaseModel, Field, validator
except ModuleNotFoundError:
from pydantic import BaseModel, Field, validator
from pydantic import BaseModel, Field, validator # type: ignore

from .dimensions import DataIdValue, SerializedDataCoordinate
from .utils import globToRegex
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/registry/obscore/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
try:
from pydantic.v1 import BaseModel, StrictBool, StrictFloat, StrictInt, StrictStr, validator
except ModuleNotFoundError:
from pydantic import BaseModel, StrictBool, StrictFloat, StrictInt, StrictStr, validator
from pydantic import BaseModel, StrictBool, StrictFloat, StrictInt, StrictStr, validator # type: ignore


class ExtraColumnType(str, enum.Enum):
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/registry/wildcards.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
try:
from pydantic.v1 import BaseModel
except ModuleNotFoundError:
from pydantic import BaseModel
from pydantic import BaseModel # type: ignore

from ..core import DatasetType
from ..core.utils import globToRegex
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/tests/_examplePythonTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
try:
from pydantic.v1 import BaseModel
except ModuleNotFoundError:
from pydantic import BaseModel
from pydantic import BaseModel # type: ignore

if TYPE_CHECKING:
from lsst.daf.butler import Butler, Datastore, FormatterFactory
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/tests/dict_convertible_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
try:
from pydantic.v1 import BaseModel, Field
except ModuleNotFoundError:
from pydantic import BaseModel, Field
from pydantic import BaseModel, Field # type: ignore


class DictConvertibleModel(BaseModel):
Expand Down

0 comments on commit 9851811

Please sign in to comment.