lsst-utils 25.2023.600__py3-none-any.whl → 29.2025.4800__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. lsst/utils/__init__.py +0 -3
  2. lsst/utils/_packaging.py +2 -0
  3. lsst/utils/argparsing.py +79 -0
  4. lsst/utils/classes.py +27 -9
  5. lsst/utils/db_auth.py +339 -0
  6. lsst/utils/deprecated.py +10 -7
  7. lsst/utils/doImport.py +8 -9
  8. lsst/utils/inheritDoc.py +34 -6
  9. lsst/utils/introspection.py +285 -19
  10. lsst/utils/iteration.py +193 -7
  11. lsst/utils/logging.py +155 -105
  12. lsst/utils/packages.py +324 -82
  13. lsst/utils/plotting/__init__.py +15 -0
  14. lsst/utils/plotting/figures.py +159 -0
  15. lsst/utils/plotting/limits.py +155 -0
  16. lsst/utils/plotting/publication_plots.py +184 -0
  17. lsst/utils/plotting/rubin.mplstyle +46 -0
  18. lsst/utils/tests.py +231 -102
  19. lsst/utils/threads.py +9 -3
  20. lsst/utils/timer.py +207 -110
  21. lsst/utils/usage.py +6 -6
  22. lsst/utils/version.py +1 -1
  23. lsst/utils/wrappers.py +74 -29
  24. {lsst_utils-25.2023.600.dist-info → lsst_utils-29.2025.4800.dist-info}/METADATA +19 -15
  25. lsst_utils-29.2025.4800.dist-info/RECORD +32 -0
  26. {lsst_utils-25.2023.600.dist-info → lsst_utils-29.2025.4800.dist-info}/WHEEL +1 -1
  27. lsst/utils/_forwarded.py +0 -28
  28. lsst/utils/backtrace/__init__.py +0 -33
  29. lsst/utils/ellipsis.py +0 -54
  30. lsst/utils/get_caller_name.py +0 -45
  31. lsst_utils-25.2023.600.dist-info/RECORD +0 -29
  32. {lsst_utils-25.2023.600.dist-info → lsst_utils-29.2025.4800.dist-info/licenses}/COPYRIGHT +0 -0
  33. {lsst_utils-25.2023.600.dist-info → lsst_utils-29.2025.4800.dist-info/licenses}/LICENSE +0 -0
  34. {lsst_utils-25.2023.600.dist-info → lsst_utils-29.2025.4800.dist-info}/top_level.txt +0 -0
  35. {lsst_utils-25.2023.600.dist-info → lsst_utils-29.2025.4800.dist-info}/zip-safe +0 -0
lsst/utils/wrappers.py CHANGED
@@ -9,12 +9,15 @@
9
9
  # Use of this source code is governed by a 3-clause BSD-style
10
10
  # license that can be found in the LICENSE file.
11
11
 
12
+ from __future__ import annotations
13
+
12
14
  import sys
13
15
  import types
16
+ from typing import Any
14
17
 
15
18
  import numpy as np
16
19
 
17
- __all__ = ("continueClass", "inClass", "TemplateMeta")
20
+ __all__ = ("TemplateMeta", "continueClass", "inClass")
18
21
 
19
22
 
20
23
  INTRINSIC_SPECIAL_ATTRIBUTES = frozenset(
@@ -32,13 +35,25 @@ INTRINSIC_SPECIAL_ATTRIBUTES = frozenset(
32
35
  )
33
36
 
34
37
 
35
- def isAttributeSafeToTransfer(name, value):
38
+ def isAttributeSafeToTransfer(name: str, value: Any) -> bool:
36
39
  """Return True if an attribute is safe to monkeypatch-transfer to another
37
40
  class.
38
41
 
39
42
  This rejects special methods that are defined automatically for all
40
43
  classes, leaving only those explicitly defined in a class decorated by
41
44
  `continueClass` or registered with an instance of `TemplateMeta`.
45
+
46
+ Parameters
47
+ ----------
48
+ name : `str`
49
+ The name of the attribute to check.
50
+ value : `~typing.Any`
51
+ The value of the attribute.
52
+
53
+ Returns
54
+ -------
55
+ `bool`
56
+ Whether the attribute is safe to monkeypatch-transfer.
42
57
  """
43
58
  if name.startswith("__") and (
44
59
  value is getattr(object, name, None) or name in INTRINSIC_SPECIAL_ATTRIBUTES
@@ -58,6 +73,7 @@ def continueClass(cls):
58
73
  class Foo:
59
74
  pass
60
75
 
76
+
61
77
  @continueClass
62
78
  class Foo:
63
79
  def run(self):
@@ -76,7 +92,6 @@ def continueClass(cls):
76
92
  Python's built-in `super` function does not behave properly in classes
77
93
  decorated with `continueClass`. Base class methods must be invoked
78
94
  directly using their explicit types instead.
79
-
80
95
  """
81
96
  orig = getattr(sys.modules[cls.__module__], cls.__name__)
82
97
  for name in dir(cls):
@@ -91,9 +106,17 @@ def continueClass(cls):
91
106
  return orig
92
107
 
93
108
 
94
- def inClass(cls, name=None):
109
+ def inClass(cls, name: str | None = None):
95
110
  """Add the decorated function to the given class as a method.
96
111
 
112
+ Parameters
113
+ ----------
114
+ name : `str` or `None`, optional
115
+ Name to be associated with the decorated function if the default
116
+ can not be determined.
117
+
118
+ Examples
119
+ --------
97
120
  For example:
98
121
 
99
122
  .. code-block:: python
@@ -101,6 +124,7 @@ def inClass(cls, name=None):
101
124
  class Foo:
102
125
  pass
103
126
 
127
+
104
128
  @inClass(Foo)
105
129
  def run(self):
106
130
  return None
@@ -113,6 +137,8 @@ def inClass(cls, name=None):
113
137
  def run(self):
114
138
  return None
115
139
 
140
+ Notes
141
+ -----
116
142
  Standard decorators like ``classmethod``, ``staticmethod``, and
117
143
  ``property`` may be used *after* this decorator. Custom decorators
118
144
  may only be used if they return an object with a ``__name__`` attribute
@@ -135,7 +161,7 @@ def inClass(cls, name=None):
135
161
  # property has fget but no __name__
136
162
  name1 = func.fget.__name__
137
163
  else:
138
- raise ValueError("Could not guess attribute name for '{}'.".format(func))
164
+ raise ValueError(f"Could not guess attribute name for '{func}'.")
139
165
  setattr(cls, name1, func)
140
166
  return func
141
167
 
@@ -167,9 +193,11 @@ class TemplateMeta(type):
167
193
  import numpy as np
168
194
  from ._image import ImageF, ImageD
169
195
 
196
+
170
197
  class Image(metaclass=TemplateMeta):
171
198
  pass
172
199
 
200
+
173
201
  Image.register(np.float32, ImageF)
174
202
  Image.register(np.float64, ImageD)
175
203
  Image.alias("F", ImageF)
@@ -210,10 +238,10 @@ class TemplateMeta(type):
210
238
  .. code-block:: python
211
239
 
212
240
  class Image(metaclass=TemplateMeta):
213
-
214
241
  def sum(self):
215
242
  return np.sum(self.getArray())
216
243
 
244
+
217
245
  Image.register(np.float32, ImageF)
218
246
  Image.register(np.float64, ImageD)
219
247
 
@@ -248,7 +276,6 @@ class TemplateMeta(type):
248
276
  Python's built-in `super` function does not behave properly in classes
249
277
  that have `TemplateMeta` as their metaclass (which should be rare, as
250
278
  TemplateMeta ABCs will have base classes of their own)..
251
-
252
279
  """
253
280
 
254
281
  def __new__(cls, name, bases, attrs):
@@ -268,7 +295,7 @@ class TemplateMeta(type):
268
295
  attrs["TEMPLATE_DEFAULTS"] = attrs["_inherited"].pop(
269
296
  "TEMPLATE_DEFAULTS", (None,) * len(attrs["TEMPLATE_PARAMS"])
270
297
  )
271
- attrs["_registry"] = dict()
298
+ attrs["_registry"] = {}
272
299
  self = type.__new__(cls, name, bases, attrs)
273
300
 
274
301
  if len(self.TEMPLATE_PARAMS) == 0:
@@ -296,8 +323,8 @@ class TemplateMeta(type):
296
323
  # indices are only tuples if there are multiple elements
297
324
  clz = cls._registry.get(key[0] if len(key) == 1 else key, None)
298
325
  if clz is None:
299
- d = {k: v for k, v in zip(cls.TEMPLATE_PARAMS, key)}
300
- raise TypeError("No registered subclass for {}.".format(d))
326
+ d = dict(zip(cls.TEMPLATE_PARAMS, key))
327
+ raise TypeError(f"No registered subclass for {d}.")
301
328
  return clz(*args, **kwds)
302
329
 
303
330
  def __subclasscheck__(cls, subclass):
@@ -305,20 +332,14 @@ class TemplateMeta(type):
305
332
  # any registered type or true subclass thereof.
306
333
  if subclass in cls._registry.values():
307
334
  return True
308
- for v in cls._registry.values():
309
- if issubclass(subclass, v):
310
- return True
311
- return False
335
+ return any(issubclass(subclass, v) for v in cls._registry.values())
312
336
 
313
337
  def __instancecheck__(cls, instance):
314
338
  # Special method hook for the isinstance built-in: we return true for
315
339
  # an instance of any registered type or true subclass thereof.
316
340
  if type(instance) in cls._registry.values():
317
341
  return True
318
- for v in cls._registry.values():
319
- if isinstance(instance, v):
320
- return True
321
- return False
342
+ return any(isinstance(instance, v) for v in cls._registry.values())
322
343
 
323
344
  def __subclasses__(cls):
324
345
  """Return a tuple of all classes that inherit from this class."""
@@ -327,11 +348,18 @@ class TemplateMeta(type):
327
348
  # functionality.
328
349
  return tuple(set(cls._registry.values()))
329
350
 
330
- def register(cls, key, subclass):
351
+ def register(cls, key, subclass) -> None:
331
352
  """Register a subclass of this ABC with the given key (a string,
332
353
  number, type, or other hashable).
333
354
 
334
355
  Register may only be called once for a given key or a given subclass.
356
+
357
+ Parameters
358
+ ----------
359
+ key : `str` or `numbers.Number` or `None` or `collections.abc.Hashable`
360
+ Key to use for registration.
361
+ subclass : `type`
362
+ Subclass to register.
335
363
  """
336
364
  if key is None:
337
365
  raise ValueError("None may not be used as a key.")
@@ -341,8 +369,8 @@ class TemplateMeta(type):
341
369
  if len(cls.TEMPLATE_PARAMS) == 1:
342
370
  d = {cls.TEMPLATE_PARAMS[0]: key}
343
371
  else:
344
- d = {k: v for k, v in zip(cls.TEMPLATE_PARAMS, key)}
345
- raise KeyError("Another subclass is already registered with {}".format(d))
372
+ d = dict(zip(cls.TEMPLATE_PARAMS, key))
373
+ raise KeyError(f"Another subclass is already registered with {d}")
346
374
  # If the key used to register a class matches the default key,
347
375
  # make the static methods available through the ABC
348
376
  if cls.TEMPLATE_DEFAULTS:
@@ -394,22 +422,27 @@ class TemplateMeta(type):
394
422
  setattrSafe(p, k)
395
423
  else:
396
424
  raise ValueError(
397
- "key must have {} elements (one for each of {})".format(
398
- len(cls.TEMPLATE_PARAMS), cls.TEMPLATE_PARAMS
399
- )
425
+ f"key must have {len(cls.TEMPLATE_PARAMS)} elements (one for each of {cls.TEMPLATE_PARAMS})"
400
426
  )
401
427
 
402
428
  for name, attr in cls._inherited.items():
403
429
  setattr(subclass, name, attr)
404
430
 
405
- def alias(cls, key, subclass):
431
+ def alias(cls, key, subclass) -> None:
406
432
  """Add an alias that allows an existing subclass to be accessed with a
407
433
  different key.
434
+
435
+ Parameters
436
+ ----------
437
+ key : `str` or `numbers.Number` or `None` or `collections.abc.Hashable`
438
+ Key to use for aliasing.
439
+ subclass : `type`
440
+ Subclass to alias.
408
441
  """
409
442
  if key is None:
410
443
  raise ValueError("None may not be used as a key.")
411
444
  if key in cls._registry:
412
- raise KeyError("Cannot multiply-register key {}".format(key))
445
+ raise KeyError(f"Cannot multiply-register key {key}")
413
446
  primaryKey = tuple(getattr(subclass, p, None) for p in cls.TEMPLATE_PARAMS)
414
447
  if len(primaryKey) == 1:
415
448
  # indices are only tuples if there are multiple elements
@@ -447,8 +480,20 @@ class TemplateMeta(type):
447
480
  """Return an iterable of (key, subclass) pairs."""
448
481
  return cls._registry.items()
449
482
 
450
- def get(cls, key, default=None):
451
- """Return the subclass associated with the given key (including
452
- aliases), or ``default`` if the key is not recognized.
483
+ def get(cls, key, default=None) -> type:
484
+ """Return the subclass associated with the given key.
485
+
486
+ Parameters
487
+ ----------
488
+ key : `~collections.abc.Hashable`
489
+ Key to query.
490
+ default : `~typing.Any` or `None`, optional
491
+ Default value to return if ``key`` is not found.
492
+
493
+ Returns
494
+ -------
495
+ `type`
496
+ Subclass with the given key. Includes aliases. Returns ``default``
497
+ if the key is not recognized.
453
498
  """
454
499
  return cls._registry.get(key, default)
@@ -1,32 +1,36 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: lsst-utils
3
- Version: 25.2023.600
3
+ Version: 29.2025.4800
4
4
  Summary: Utility functions from Rubin Observatory Data Management for the Legacy Survey of Space and Time (LSST).
5
5
  Author-email: Rubin Observatory Data Management <dm-admin@lists.lsst.org>
6
- License: BSD 3-Clause License
6
+ License-Expression: BSD-3-Clause
7
7
  Project-URL: Homepage, https://github.com/lsst/utils
8
8
  Keywords: lsst
9
9
  Classifier: Intended Audience :: Developers
10
- Classifier: License :: OSI Approved :: BSD License
11
10
  Classifier: Operating System :: OS Independent
12
11
  Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.8
14
- Classifier: Programming Language :: Python :: 3.9
15
12
  Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Requires-Python: >=3.10.0
16
18
  Description-Content-Type: text/x-rst
17
19
  License-File: COPYRIGHT
18
20
  License-File: LICENSE
19
- Requires-Dist: numpy (>=1.17)
20
- Requires-Dist: psutil (>=5.7)
21
- Requires-Dist: deprecated (>=1.2)
22
- Requires-Dist: pyyaml (>=5.1)
23
- Requires-Dist: astropy (>=5.0)
21
+ Requires-Dist: numpy>=1.17
22
+ Requires-Dist: psutil>=5.7
23
+ Requires-Dist: deprecated>=1.2
24
+ Requires-Dist: pyyaml>=5.1
25
+ Requires-Dist: astropy>=5.0
26
+ Requires-Dist: structlog
24
27
  Requires-Dist: threadpoolctl
25
28
  Provides-Extra: test
26
- Requires-Dist: pytest (>=3.2) ; extra == 'test'
27
- Requires-Dist: flake8 (>=3.7.5) ; extra == 'test'
28
- Requires-Dist: pytest-flake8 (>=1.0.4) ; extra == 'test'
29
- Requires-Dist: pytest-openfiles (>=0.5.0) ; extra == 'test'
29
+ Requires-Dist: pytest>=3.2; extra == "test"
30
+ Provides-Extra: plotting
31
+ Requires-Dist: matplotlib; extra == "plotting"
32
+ Requires-Dist: seaborn; extra == "plotting"
33
+ Dynamic: license-file
30
34
 
31
35
  ==========
32
36
  lsst-utils
@@ -0,0 +1,32 @@
1
+ lsst/__init__.py,sha256=SC6Iu8isb6RY7Axl4OPdrqDt38MVVRn8vbw8qQ1ZUnk,499
2
+ lsst/utils/__init__.py,sha256=LXmENKqD7G9s8CTV9zxdpM35eaDSv5hLvm8ycXu9hHk,569
3
+ lsst/utils/_packaging.py,sha256=4laBi-lHsNYHxms9tjyjMVwfmnwAltt-I2HWP-RE3Ds,1422
4
+ lsst/utils/argparsing.py,sha256=ITLsiANA4FEXc_ZKakX_U1beVez6WHdNoMeS8pC2CeY,2963
5
+ lsst/utils/classes.py,sha256=uTs1Coin5TlpH2rwD5RYh3m_JgMBYVnkg2jklb9Djnc,5467
6
+ lsst/utils/db_auth.py,sha256=qREqUDI7jXr49lY3bKhe75mbZsuAPu2zHaAtel30EEY,12924
7
+ lsst/utils/deprecated.py,sha256=vGypsklkL_aAdtovvF0WS4785zZY1jZMZC1aKm6e2EM,3498
8
+ lsst/utils/doImport.py,sha256=JbD_AR1GQ1PVdK--OJy5tVz1U2Kabe1ETyQoyaq6rpQ,4241
9
+ lsst/utils/inheritDoc.py,sha256=doMsQKcDssZvsTAYJSmHxOWXM4D1wPrDSCTHiaRGUvw,2719
10
+ lsst/utils/introspection.py,sha256=Y1ImDWl5i1O9iRbOoSJhr8Rz57y-_WMgwDtbGJBVxJk,14735
11
+ lsst/utils/iteration.py,sha256=FHDGWcAbWzJdN1RVP-LdtatBfmCW9x_2MdQ5iwmT1sE,9278
12
+ lsst/utils/logging.py,sha256=TPtKK5ShYAEeIFlqhYkEGGSDeUwiMWWzOb1CQGHMBlU,16256
13
+ lsst/utils/packages.py,sha256=XGtZCGkxqUCiyHi6LZDakV7tgoxtvABww7Haen84Yj8,27530
14
+ lsst/utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ lsst/utils/tests.py,sha256=eEcgGuHfaLorLlPUqwUNbWeO4A_2_r8ON8vTdlhcrek,39185
16
+ lsst/utils/threads.py,sha256=WNl3uvbE7bx5UyxTX0fwN5AkU3Yty_m8y_pMKcMCdv8,2551
17
+ lsst/utils/timer.py,sha256=p_qOEQEIqfQubQJmaN4pK-3YUqZCocY08fBgpnSTXh0,21961
18
+ lsst/utils/usage.py,sha256=qunydx-KlcbNp-vFcBtvBayWwZAa0tHtSWvz5BycvLA,4598
19
+ lsst/utils/version.py,sha256=MHZJr_Yoevn1SeqerO6dmfTP3xtJLGxPmEi-9Jpl380,55
20
+ lsst/utils/wrappers.py,sha256=KCvsrGXziLQ5pC8ytiFEXeDH9mBSo8eCZ8g08f7s404,19209
21
+ lsst/utils/plotting/__init__.py,sha256=OEAZv2W12UAcUfDxH5H_k8v7cK4fVTOssuqNksZTuIs,507
22
+ lsst/utils/plotting/figures.py,sha256=pLkD7MpYk1Zs2hozA2-6r_uUd1129Uoi9EAEkMvtCjk,4356
23
+ lsst/utils/plotting/limits.py,sha256=6ilPmb4wg4aVtjlBgm75FPBrjDVSkW_ywZrj_QIQD2U,5839
24
+ lsst/utils/plotting/publication_plots.py,sha256=-uOL2ptI3N52KxfhtJNsUt7SqeGdT78GF-_QjHKKmV8,5016
25
+ lsst/utils/plotting/rubin.mplstyle,sha256=mjLPYzolUjeCXq8z4ltXLvEf8IuyT4TS0Nx8JJ05v6I,1063
26
+ lsst_utils-29.2025.4800.dist-info/licenses/COPYRIGHT,sha256=I6Bxnp_LkIqDjafZNIXM8jfjYWC4XIlpNpZ7jkdeZK0,361
27
+ lsst_utils-29.2025.4800.dist-info/licenses/LICENSE,sha256=7wrtgl8meQ0_RIuv2TjIKpAnNrl-ODH-QLwyHe9citI,1516
28
+ lsst_utils-29.2025.4800.dist-info/METADATA,sha256=vsgVZPk0hRxE9PQCEMowwthncqar_PjU1KwSk-6eVE8,1770
29
+ lsst_utils-29.2025.4800.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
30
+ lsst_utils-29.2025.4800.dist-info/top_level.txt,sha256=eUWiOuVVm9wwTrnAgiJT6tp6HQHXxIhj2QSZ7NYZH80,5
31
+ lsst_utils-29.2025.4800.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
32
+ lsst_utils-29.2025.4800.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
lsst/utils/_forwarded.py DELETED
@@ -1,28 +0,0 @@
1
- # This file is part of utils.
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
- __all__ = ("demangleType",)
13
-
14
- """Functions that have been moved to the cpputils package and should no
15
- longer be used from this package."""
16
-
17
- from deprecated.sphinx import deprecated
18
-
19
- _REASON = "This function has been moved to the cpputils package. Will be removed after v25."
20
- _VERSION_REMOVED = "v23"
21
-
22
-
23
- @deprecated(reason=_REASON, version=_VERSION_REMOVED, category=FutureWarning)
24
- def demangleType(type_name: str) -> str:
25
- """Demangle a C++ type string."""
26
- import lsst.cpputils
27
-
28
- return lsst.cpputils.demangleType(type_name)
@@ -1,33 +0,0 @@
1
- # This file is part of utils.
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
- """Temporary forwarding of backtrace to cpputils package."""
12
-
13
- __all__ = ["isEnabled"]
14
-
15
- from deprecated.sphinx import deprecated
16
-
17
- try:
18
- # For now, ensure that backtrace has been imported if somebody
19
- # is relying on it from a lsst.utils import. Treat it as an optional
20
- # import.
21
- import lsst.cpputils.backtrace
22
- except ImportError:
23
- pass
24
-
25
- from .._forwarded import _REASON, _VERSION_REMOVED
26
-
27
-
28
- @deprecated(reason=_REASON, version=_VERSION_REMOVED, category=FutureWarning)
29
- def isEnabled() -> bool:
30
- """Check that backtrace is enabled."""
31
- from lsst.cpputils import backtrace
32
-
33
- return backtrace.isEnabled()
lsst/utils/ellipsis.py DELETED
@@ -1,54 +0,0 @@
1
- # This file is part of utils.
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
- """
13
- A type-annotation workaround for ``...`` not having an exposed type in Python.
14
-
15
- This module provides ``Ellipsis`` and ``EllipsisType`` symbols that are
16
- conditionally defined to point to the built-in "``...``" singleton and its type
17
- (respectively) at runtime, and an enum class and instance if
18
- `typing.TYPE_CHECKING` is `True` (an approach first suggested
19
- `here <https://github.com/python/typing/issues/684#issuecomment-548203158>`_).
20
- Type checkers should recognize enum literals as singletons, making this pair
21
- behave as expected under ``is`` comparisons and type-narrowing expressions,
22
- such as::
23
-
24
- v: EllipsisType | int
25
- if v is not Ellipsis:
26
- v += 2 # type checker should now see v as a pure int
27
-
28
- This works best when there is a clear boundary between code that needs to be
29
- type-checked and can use ``Ellipsis`` instead of a literal "``...``", and
30
- calling code that is either not type-checked or uses `typing.Any` to accept
31
- literal "``...``" values.
32
- """
33
-
34
- from __future__ import annotations
35
-
36
- __all__ = ("Ellipsis", "EllipsisType")
37
-
38
- from typing import TYPE_CHECKING
39
-
40
- if TYPE_CHECKING:
41
- from enum import Enum
42
-
43
- class EllipsisType(Enum):
44
- Ellipsis = "..."
45
-
46
- Ellipsis = EllipsisType.Ellipsis
47
-
48
- else:
49
- try:
50
- # Present in Python >= 3.10
51
- from types import EllipsisType
52
- except ImportError:
53
- EllipsisType = type(Ellipsis)
54
- Ellipsis = Ellipsis
@@ -1,45 +0,0 @@
1
- # This file is part of utils.
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
- __all__ = ["get_caller_name"]
13
-
14
- from deprecated.sphinx import deprecated
15
-
16
- from .introspection import get_caller_name as caller_name
17
-
18
-
19
- @deprecated(
20
- reason="get_caller_name has moved to `lsst.utils.introspection.get_caller_name`."
21
- " Will be removed in v26.",
22
- version="v24",
23
- category=FutureWarning,
24
- )
25
- def get_caller_name(skip: int = 2) -> str:
26
- """Get the name of the caller method.
27
-
28
- Any item that cannot be determined (or is not relevant, e.g. a free
29
- function has no class) is silently omitted, along with an
30
- associated separator.
31
-
32
- Parameters
33
- ----------
34
- skip : `int`
35
- How many levels of stack to skip while getting caller name;
36
- 1 means "who calls me", 2 means "who calls my caller", etc.
37
-
38
- Returns
39
- -------
40
- name : `str`
41
- Name of the caller as a string in the form ``module.class.method``.
42
- An empty string is returned if ``skip`` exceeds the stack height.
43
- """
44
- # Offset the stack level to account for redirect and deprecated wrapper.
45
- return caller_name(stacklevel=skip + 2)
@@ -1,29 +0,0 @@
1
- lsst/__init__.py,sha256=SC6Iu8isb6RY7Axl4OPdrqDt38MVVRn8vbw8qQ1ZUnk,499
2
- lsst/utils/__init__.py,sha256=aRSuP1qwHeZcR0RGgLfife7vejKTZ8jOs9yCNTIVrgo,651
3
- lsst/utils/_forwarded.py,sha256=Zb-jviBl6y7MbSU37ZFIIVdGTAl194LvkTlrPr5rH_0,923
4
- lsst/utils/_packaging.py,sha256=tWtj5ORSczBKDWt4KURfrRu0Nd1IWMil7jPbqRnJE2Q,1386
5
- lsst/utils/classes.py,sha256=chJ84-v9clYO_UNTruIDfhOh06_qfqYC3sAjUS1uTa0,4790
6
- lsst/utils/deprecated.py,sha256=XJ99-A1NSsLw6RHK6jnuOT05idjIEM_Ff_9rxcXh3lI,3437
7
- lsst/utils/doImport.py,sha256=NA1iEqWEX_MlpA-2qW2keE1W6ML5o3gdJvEceHX-_s4,4269
8
- lsst/utils/ellipsis.py,sha256=9KfnLFQnOgFOm2amOlWQy9RfkdQcC8TSriluYdBnVdQ,1791
9
- lsst/utils/get_caller_name.py,sha256=7sa0__1Hk2dL9BL-6S385tYKgalsbcAcamS7Bj2enMw,1454
10
- lsst/utils/inheritDoc.py,sha256=unxKOKYXwNARzLBpIKA-WipsQfwnKsjI9GAig1OlzCw,1614
11
- lsst/utils/introspection.py,sha256=ig-V7WlrBOAxTlff1s8EX8aaEEvct3KqngRiiLQxa7k,5703
12
- lsst/utils/iteration.py,sha256=5Djh_IZoszcoMzuB6-XYcb5WN2HEe0vJJkkuqRguqyo,3181
13
- lsst/utils/logging.py,sha256=5eOL7IBgd4ChayioFkeQlMnnpU-D5SXx_IK0miBBqWw,14180
14
- lsst/utils/packages.py,sha256=uUXM9Igsf5fQCNR8vhs33Z7JEXM3LQpNtaG0b6DXJb8,19159
15
- lsst/utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- lsst/utils/tests.py,sha256=qFEheTewb_qm7buEOWHi-OJLNLD7ByrP4wPnmUfyOQs,34934
17
- lsst/utils/threads.py,sha256=FzB7P-izCF_ivdgKLFWzP-Tfcy2C2SQZWB2SsF42w5I,2347
18
- lsst/utils/timer.py,sha256=ci4XS9K9Q4DXUtvUDl_0b99q-9IeWI_hlZ0dXKWeWXA,17944
19
- lsst/utils/usage.py,sha256=PO0ZrriBTglC6wYXVPNI3oS7wnqyVjcWLE2H6bJIed4,4607
20
- lsst/utils/version.py,sha256=Ho7723UBCHsCqcYi3Xq_4ovwScuA0f5szGK6VsSIaWM,54
21
- lsst/utils/wrappers.py,sha256=RG5XmwuCa19wOCJENUIaI3sA0dIDJ8Y6ulkC7ZcW7oc,18090
22
- lsst/utils/backtrace/__init__.py,sha256=_z3ZT5BgpX1tdniYiMS94rMH6N2-QXxo66BOXt0fbEk,1015
23
- lsst_utils-25.2023.600.dist-info/COPYRIGHT,sha256=I6Bxnp_LkIqDjafZNIXM8jfjYWC4XIlpNpZ7jkdeZK0,361
24
- lsst_utils-25.2023.600.dist-info/LICENSE,sha256=7wrtgl8meQ0_RIuv2TjIKpAnNrl-ODH-QLwyHe9citI,1516
25
- lsst_utils-25.2023.600.dist-info/METADATA,sha256=t5ii_UdVbQa-fW4alCJ0yklcZqu7Am0R0dIvn1x-uUM,1710
26
- lsst_utils-25.2023.600.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
27
- lsst_utils-25.2023.600.dist-info/top_level.txt,sha256=eUWiOuVVm9wwTrnAgiJT6tp6HQHXxIhj2QSZ7NYZH80,5
28
- lsst_utils-25.2023.600.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
29
- lsst_utils-25.2023.600.dist-info/RECORD,,