Skip to content

Commit

Permalink
Merge pull request #602 from lsst/tickets/DM-32386
Browse files Browse the repository at this point in the history
Avoid string types with ClassVar
  • Loading branch information
rra committed Nov 15, 2021
2 parents d67b257 + 90b8334 commit 3fdd349
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
14 changes: 6 additions & 8 deletions python/lsst/daf/butler/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from __future__ import annotations

__all__ = ("ButlerMDC", "ButlerLogRecords", "ButlerLogRecordHandler",
"ButlerLogRecord", "JsonLogFormatter")

Expand Down Expand Up @@ -192,7 +190,7 @@ class Config:
allow_mutation = False

@classmethod
def from_record(cls, record: LogRecord) -> ButlerLogRecord:
def from_record(cls, record: LogRecord) -> "ButlerLogRecord":
"""Create a new instance from a `~logging.LogRecord`.
Parameters
Expand Down Expand Up @@ -274,7 +272,7 @@ class ButlerLogRecords(BaseModel):
_log_format: Optional[str] = PrivateAttr(None)

@classmethod
def from_records(cls, records: Iterable[ButlerLogRecord]) -> ButlerLogRecords:
def from_records(cls, records: Iterable[ButlerLogRecord]) -> "ButlerLogRecords":
"""Create collection from iterable.
Parameters
Expand All @@ -285,7 +283,7 @@ def from_records(cls, records: Iterable[ButlerLogRecord]) -> ButlerLogRecords:
return cls(__root__=list(records))

@classmethod
def from_file(cls, filename: str) -> ButlerLogRecords:
def from_file(cls, filename: str) -> "ButlerLogRecords":
"""Read records from file.
Parameters
Expand Down Expand Up @@ -354,7 +352,7 @@ def _detect_model(startdata: Union[str, bytes]) -> bool:
return False

@classmethod
def from_stream(cls, stream: IO) -> ButlerLogRecords:
def from_stream(cls, stream: IO) -> "ButlerLogRecords":
"""Read records from I/O stream.
Parameters
Expand Down Expand Up @@ -391,7 +389,7 @@ def from_stream(cls, stream: IO) -> ButlerLogRecords:
return cls.from_records(records)

@classmethod
def from_raw(cls, serialized: Union[str, bytes]) -> ButlerLogRecords:
def from_raw(cls, serialized: Union[str, bytes]) -> "ButlerLogRecords":
"""Parse raw serialized form and return records.
Parameters
Expand Down Expand Up @@ -464,7 +462,7 @@ def __iter__(self) -> Iterator[ButlerLogRecord]: # type: ignore
def __setitem__(self, index: int, value: Record) -> None:
self.__root__[index] = self._validate_record(value)

def __getitem__(self, index: Union[slice, int]) -> Union[ButlerLogRecords, ButlerLogRecord]:
def __getitem__(self, index: Union[slice, int]) -> "Union[ButlerLogRecords, ButlerLogRecord]":
# Handles slices and returns a new collection in that
# case.
item = self.__root__[index]
Expand Down
4 changes: 1 addition & 3 deletions python/lsst/daf/butler/core/serverModels.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from __future__ import annotations

__all__ = (
"QueryDatasetsModel",
"QueryDataIdsModel",
Expand Down Expand Up @@ -116,7 +114,7 @@ def expression(self) -> Any:
return expression

@classmethod
def from_expression(cls, expression: Any) -> ExpressionQueryParameter:
def from_expression(cls, expression: Any) -> "ExpressionQueryParameter":
"""Convert a standard dataset type expression to wire form."""
if expression is ...:
return cls()
Expand Down

0 comments on commit 3fdd349

Please sign in to comment.