Skip to content

Commit

Permalink
Hide pydantic docstrings from sphinx.
Browse files Browse the repository at this point in the history
This isn't pretty at all, but I have yet to find another way.
  • Loading branch information
TallJimbo committed Dec 21, 2023
1 parent 5ab2e80 commit a512a07
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
22 changes: 22 additions & 0 deletions python/lsst/pipe/base/_task_metadata.py
Expand Up @@ -29,6 +29,7 @@

import itertools
import numbers
import sys
import warnings
from collections.abc import Collection, Iterator, Mapping, Sequence
from typing import Any, Protocol
Expand Down Expand Up @@ -571,6 +572,27 @@ def _validate_value(self, value: Any) -> tuple[str, Any]:

raise ValueError(f"TaskMetadata does not support values of type {value!r}.")

# Work around the fact that Sphinx chokes on Pydantic docstring formatting,
# when we inherit those docstrings in our public classes.
if "sphinx" in sys.modules:

def copy(self, *args: Any, **kwargs: Any) -> Any:

Check warning on line 579 in python/lsst/pipe/base/_task_metadata.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/_task_metadata.py#L579

Added line #L579 was not covered by tests
"""See `pydantic.BaseModel.copy`."""
return super().copy(*args, **kwargs)

Check warning on line 581 in python/lsst/pipe/base/_task_metadata.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/_task_metadata.py#L581

Added line #L581 was not covered by tests

def model_dump(self, *args: Any, **kwargs: Any) -> Any:

Check warning on line 583 in python/lsst/pipe/base/_task_metadata.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/_task_metadata.py#L583

Added line #L583 was not covered by tests
"""See `pydantic.BaseModel.model_dump`."""
return super().model_dump(*args, **kwargs)

Check warning on line 585 in python/lsst/pipe/base/_task_metadata.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/_task_metadata.py#L585

Added line #L585 was not covered by tests

def model_copy(self, *args: Any, **kwargs: Any) -> Any:

Check warning on line 587 in python/lsst/pipe/base/_task_metadata.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/_task_metadata.py#L587

Added line #L587 was not covered by tests
"""See `pydantic.BaseModel.model_copy`."""
return super().model_copy(*args, **kwargs)

Check warning on line 589 in python/lsst/pipe/base/_task_metadata.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/_task_metadata.py#L589

Added line #L589 was not covered by tests

@classmethod

Check warning on line 591 in python/lsst/pipe/base/_task_metadata.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/_task_metadata.py#L591

Added line #L591 was not covered by tests
def model_json_schema(cls, *args: Any, **kwargs: Any) -> Any:
"""See `pydantic.BaseModel.model_json_schema`."""
return super().model_json_schema(*args, **kwargs)

Check warning on line 594 in python/lsst/pipe/base/_task_metadata.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/_task_metadata.py#L594

Added line #L594 was not covered by tests


# Needed because a TaskMetadata can contain a TaskMetadata.
TaskMetadata.model_rebuild()
43 changes: 43 additions & 0 deletions python/lsst/pipe/base/tests/mocks/_storage_class.py
Expand Up @@ -37,6 +37,7 @@
"is_mock_name",
)

import sys
import uuid
from collections.abc import Callable, Iterable, Mapping
from typing import Any, cast
Expand Down Expand Up @@ -202,6 +203,27 @@ def make_derived(self, **kwargs: Any) -> MockDataset:
# it to try to optimize out the work above to make derived_ref.
return self.model_copy(update=kwargs)

Check warning on line 204 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L204

Added line #L204 was not covered by tests

# Work around the fact that Sphinx chokes on Pydantic docstring formatting,
# when we inherit those docstrings in our public classes.
if "sphinx" in sys.modules:

def copy(self, *args: Any, **kwargs: Any) -> Any:

Check warning on line 210 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L210

Added line #L210 was not covered by tests
"""See `pydantic.BaseModel.copy`."""
return super().copy(*args, **kwargs)

Check warning on line 212 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L212

Added line #L212 was not covered by tests

def model_dump(self, *args: Any, **kwargs: Any) -> Any:

Check warning on line 214 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L214

Added line #L214 was not covered by tests
"""See `pydantic.BaseModel.model_dump`."""
return super().model_dump(*args, **kwargs)

Check warning on line 216 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L216

Added line #L216 was not covered by tests

def model_copy(self, *args: Any, **kwargs: Any) -> Any:

Check warning on line 218 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L218

Added line #L218 was not covered by tests
"""See `pydantic.BaseModel.model_copy`."""
return super().model_copy(*args, **kwargs)

Check warning on line 220 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L220

Added line #L220 was not covered by tests

@classmethod

Check warning on line 222 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L222

Added line #L222 was not covered by tests
def model_json_schema(cls, *args: Any, **kwargs: Any) -> Any:
"""See `pydantic.BaseModel.model_json_schema`."""
return super().model_json_schema(*args, **kwargs)

Check warning on line 225 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L225

Added line #L225 was not covered by tests


class MockDatasetQuantum(pydantic.BaseModel):
"""Description of the quantum that produced a mock dataset.
Expand All @@ -222,6 +244,27 @@ class MockDatasetQuantum(pydantic.BaseModel):
Keys are task-internal connection names, not dataset type names.
"""

# Work around the fact that Sphinx chokes on Pydantic docstring formatting,
# when we inherit those docstrings in our public classes.
if "sphinx" in sys.modules:

def copy(self, *args: Any, **kwargs: Any) -> Any:

Check warning on line 251 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L251

Added line #L251 was not covered by tests
"""See `pydantic.BaseModel.copy`."""
return super().copy(*args, **kwargs)

Check warning on line 253 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L253

Added line #L253 was not covered by tests

def model_dump(self, *args: Any, **kwargs: Any) -> Any:

Check warning on line 255 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L255

Added line #L255 was not covered by tests
"""See `pydantic.BaseModel.model_dump`."""
return super().model_dump(*args, **kwargs)

Check warning on line 257 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L257

Added line #L257 was not covered by tests

def model_copy(self, *args: Any, **kwargs: Any) -> Any:

Check warning on line 259 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L259

Added line #L259 was not covered by tests
"""See `pydantic.BaseModel.model_copy`."""
return super().model_copy(*args, **kwargs)

Check warning on line 261 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L261

Added line #L261 was not covered by tests

@classmethod

Check warning on line 263 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L263

Added line #L263 was not covered by tests
def model_json_schema(cls, *args: Any, **kwargs: Any) -> Any:
"""See `pydantic.BaseModel.model_json_schema`."""
return super().model_json_schema(*args, **kwargs)

Check warning on line 266 in python/lsst/pipe/base/tests/mocks/_storage_class.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_storage_class.py#L266

Added line #L266 was not covered by tests


MockDataset.model_rebuild()

Expand Down

0 comments on commit a512a07

Please sign in to comment.