Coverage for python / lsst / images / json / formatters.py: 75%

12 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-05-16 07:54 +0000

1# This file is part of lsst-images. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# Use of this source code is governed by a 3-clause BSD-style 

10# license that can be found in the LICENSE file. 

11 

12"""Deprecated re-export of the unified ``lsst.images.formatters`` module. 

13 

14`lsst.images.json.formatters.GenericFormatter` exists so that deployed 

15butler configs that point Transform and Projection storage classes at 

16this path keep working. The shim overrides ``default_extension`` to 

17``.json`` so writes default to JSON output when no ``format`` write 

18parameter is supplied. 

19""" 

20 

21from __future__ import annotations 

22 

23__all__ = ("GenericFormatter",) 

24 

25import warnings 

26from typing import Any, ClassVar 

27 

28from .. import formatters as _unified 

29 

30 

31def _warn(name: str) -> None: 

32 warnings.warn( 

33 f"lsst.images.json.formatters.{name} is deprecated; " 

34 f"use lsst.images.formatters.{name} with format='json' " 

35 f"instead. The json-only formatter forwards to the unified " 

36 f"one and will be removed in a future release.", 

37 DeprecationWarning, 

38 stacklevel=3, 

39 ) 

40 

41 

42class GenericFormatter(_unified.GenericFormatter): 

43 """Deprecated alias for `lsst.images.formatters.GenericFormatter`. 

44 

45 Defaults to ``.json`` output so existing butler configs that point 

46 Transform/Projection storage classes here keep producing JSON 

47 without specifying a ``format`` write parameter. 

48 """ 

49 

50 default_extension: ClassVar[str] = ".json" 

51 

52 def __init__(self, *args: Any, **kwargs: Any) -> None: 

53 _warn("GenericFormatter") 

54 super().__init__(*args, **kwargs)