param 2.4.1rc1__tar.gz → 2.4.2__tar.gz
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.
- {param-2.4.1rc1 → param-2.4.2}/PKG-INFO +3 -2
- {param-2.4.1rc1 → param-2.4.2}/param/_utils.py +58 -7
- {param-2.4.1rc1 → param-2.4.2}/param/_version.py +2 -2
- {param-2.4.1rc1 → param-2.4.2}/param/parameterized.py +111 -20
- {param-2.4.1rc1 → param-2.4.2}/param/parameters.py +3 -3
- {param-2.4.1rc1 → param-2.4.2}/param/reactive.py +166 -23
- {param-2.4.1rc1 → param-2.4.2}/pyproject.toml +1 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testfiledeserialization.py +1 -1
- {param-2.4.1rc1 → param-2.4.2}/tests/testlist.py +8 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testparameterizedobject.py +106 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testreactive.py +482 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testrefs.py +49 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testutils.py +66 -0
- {param-2.4.1rc1 → param-2.4.2}/.gitignore +0 -0
- {param-2.4.1rc1 → param-2.4.2}/LICENSE.txt +0 -0
- {param-2.4.1rc1 → param-2.4.2}/README.md +0 -0
- {param-2.4.1rc1 → param-2.4.2}/numbergen/__init__.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/param/__init__.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/param/depends.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/param/display.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/param/ipython.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/param/mypy_plugin.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/param/py.typed +0 -0
- {param-2.4.1rc1 → param-2.4.2}/param/serializer.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/param/version.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/__init__.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/assert_types.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/conftest.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/pyrightconfig-bare.json +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testaddparameter.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testbind.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testbooleanparam.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testbytesparam.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testcalendardateparam.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testcalendardaterangeparam.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testcallable.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testclassselector.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testcolorparameter.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testcomparator.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testcompositeparams.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testcustomparam.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testdateparam.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testdaterangeparam.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testdefaultfactory.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testdefaults.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testdeprecations.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testdynamicparams.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testfileselector.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testimports.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testipythonmagic.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testjsonserialization.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testlistselector.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testmultifileselector.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testnumbergen.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testnumberparameter.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testnumpy.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testobjectselector.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testpandas.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testparamdepends.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testparameter.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testparameterizedrepr.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testparamoutput.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testparamunion.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testpathparam.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testpickle.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testrangeparameter.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testreprhtml.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testselector.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testsignatures.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/teststringparam.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testtimedependent.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testtupleparam.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testversion.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/testwatch.py +0 -0
- {param-2.4.1rc1 → param-2.4.2}/tests/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: param
|
|
3
|
-
Version: 2.4.
|
|
3
|
+
Version: 2.4.2
|
|
4
4
|
Summary: Declarative parameters for robust Python classes and a rich API for reactive programming
|
|
5
5
|
Project-URL: Homepage, https://param.holoviz.org/
|
|
6
6
|
Project-URL: Tracker, https://github.com/holoviz/param/issues
|
|
@@ -23,6 +23,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
23
23
|
Classifier: Programming Language :: Python :: 3.12
|
|
24
24
|
Classifier: Programming Language :: Python :: 3.13
|
|
25
25
|
Classifier: Programming Language :: Python :: 3.14
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
26
27
|
Classifier: Topic :: Scientific/Engineering
|
|
27
28
|
Classifier: Topic :: Software Development :: Libraries
|
|
28
29
|
Classifier: Typing :: Typed
|
|
@@ -12,7 +12,7 @@ import warnings
|
|
|
12
12
|
from collections import OrderedDict, abc, defaultdict
|
|
13
13
|
from contextlib import contextmanager
|
|
14
14
|
from textwrap import dedent
|
|
15
|
-
from threading import get_ident
|
|
15
|
+
from threading import get_ident, local
|
|
16
16
|
|
|
17
17
|
if t.TYPE_CHECKING:
|
|
18
18
|
import asyncio
|
|
@@ -544,10 +544,10 @@ def _abbreviate_paths(pathspec,named_paths):
|
|
|
544
544
|
Given a dict of (pathname,path) pairs, removes any prefix shared by all pathnames.
|
|
545
545
|
Helps keep menu items short yet unambiguous.
|
|
546
546
|
"""
|
|
547
|
-
from os.path import
|
|
547
|
+
from os.path import commonpath, dirname, sep
|
|
548
548
|
|
|
549
|
-
prefix =
|
|
550
|
-
return OrderedDict([(name[len(prefix):],path) for name,path in named_paths.items()])
|
|
549
|
+
prefix = commonpath([dirname(name)+sep for name in named_paths.keys()]+[pathspec])
|
|
550
|
+
return OrderedDict([(name[len(prefix)+1:],path) for name,path in named_paths.items()])
|
|
551
551
|
|
|
552
552
|
|
|
553
553
|
def _to_datetime(x):
|
|
@@ -608,18 +608,69 @@ def _in_ipython():
|
|
|
608
608
|
|
|
609
609
|
_running_tasks: set[asyncio.Task] = set()
|
|
610
610
|
|
|
611
|
+
_thread_state = local()
|
|
612
|
+
|
|
613
|
+
def _fallback_event_loop() -> asyncio.AbstractEventLoop:
|
|
614
|
+
"""
|
|
615
|
+
Return the event loop to drive coroutines on when nothing else is running.
|
|
616
|
+
|
|
617
|
+
The loop is cached per thread and reused, since creating one per call leaks
|
|
618
|
+
the file descriptors each loop holds. It is kept thread-local because
|
|
619
|
+
``run_until_complete`` may not be driven from two threads at once.
|
|
620
|
+
"""
|
|
621
|
+
import asyncio
|
|
622
|
+
event_loop = getattr(_thread_state, 'event_loop', None)
|
|
623
|
+
if event_loop is None or event_loop.is_closed():
|
|
624
|
+
event_loop = asyncio.new_event_loop()
|
|
625
|
+
_thread_state.event_loop = event_loop
|
|
626
|
+
return event_loop
|
|
627
|
+
|
|
628
|
+
def _drain_fallback_loop(event_loop: asyncio.AbstractEventLoop) -> None:
|
|
629
|
+
"""
|
|
630
|
+
Finish off anything left running on the fallback loop.
|
|
631
|
+
|
|
632
|
+
A coroutine driven by :func:`async_executor` may schedule further work
|
|
633
|
+
before it completes, which ``run_until_complete`` leaves pending. Since the
|
|
634
|
+
loop is reused, such a leftover would otherwise resume in the middle of an
|
|
635
|
+
unrelated drive, so it is cancelled and given the chance to clean up here.
|
|
636
|
+
"""
|
|
637
|
+
import asyncio
|
|
638
|
+
pending = [task for task in asyncio.all_tasks(event_loop) if not task.done()]
|
|
639
|
+
if not pending:
|
|
640
|
+
return
|
|
641
|
+
for task in pending:
|
|
642
|
+
task.cancel()
|
|
643
|
+
event_loop.run_until_complete(asyncio.gather(*pending, return_exceptions=True))
|
|
644
|
+
|
|
611
645
|
def async_executor(func):
|
|
646
|
+
"""
|
|
647
|
+
Schedule the awaitable returned by ``func`` on the running event loop.
|
|
648
|
+
|
|
649
|
+
Without a running loop the awaitable is instead driven to completion on a
|
|
650
|
+
loop of param's own, i.e. the call blocks the caller until the coroutine
|
|
651
|
+
has finished. Applications that can offer a loop (such as Panel) are
|
|
652
|
+
expected to override ``param.parameterized.async_executor``.
|
|
653
|
+
"""
|
|
612
654
|
import asyncio
|
|
613
655
|
try:
|
|
614
656
|
event_loop = asyncio.get_running_loop()
|
|
615
657
|
except RuntimeError:
|
|
616
|
-
event_loop =
|
|
617
|
-
if event_loop
|
|
658
|
+
event_loop = None
|
|
659
|
+
if event_loop is not None:
|
|
618
660
|
task = asyncio.ensure_future(func())
|
|
619
661
|
_running_tasks.add(task)
|
|
620
662
|
task.add_done_callback(_running_tasks.discard)
|
|
621
|
-
|
|
663
|
+
return
|
|
664
|
+
event_loop = _fallback_event_loop()
|
|
665
|
+
try:
|
|
622
666
|
event_loop.run_until_complete(func())
|
|
667
|
+
except asyncio.CancelledError:
|
|
668
|
+
# A coroutine superseded while it was being driven synchronously must
|
|
669
|
+
# not surface the cancellation in the caller, which is generally an
|
|
670
|
+
# unrelated attribute access or parameter update.
|
|
671
|
+
pass
|
|
672
|
+
finally:
|
|
673
|
+
_drain_fallback_loop(event_loop)
|
|
623
674
|
|
|
624
675
|
@t.runtime_checkable
|
|
625
676
|
class _HasTypes(t.Protocol):
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '2.4.
|
|
22
|
-
__version_tuple__ = version_tuple = (2, 4,
|
|
21
|
+
__version__ = version = '2.4.2'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 4, 2)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -1855,7 +1855,7 @@ class Parameter(_ParameterBase, t.Generic[_T]):
|
|
|
1855
1855
|
pass
|
|
1856
1856
|
|
|
1857
1857
|
super().__setattr__(attribute, value)
|
|
1858
|
-
if is_slot and attribute in _PARAMETER_CACHE_ATTRS:
|
|
1858
|
+
if is_slot and attribute in _PARAMETER_CACHE_ATTRS and value is not old:
|
|
1859
1859
|
self._invalidate_init_cache()
|
|
1860
1860
|
if has_watcher and old is not NotImplemented:
|
|
1861
1861
|
self._trigger_event(attribute, old, value)
|
|
@@ -2411,6 +2411,21 @@ class _ParametersRestorer:
|
|
|
2411
2411
|
self._restore = {}
|
|
2412
2412
|
|
|
2413
2413
|
|
|
2414
|
+
def _find_descriptor(cls: type, attr: str) -> t.Any:
|
|
2415
|
+
"""
|
|
2416
|
+
Return the descriptor implementing ``attr`` on ``cls``, or None.
|
|
2417
|
+
|
|
2418
|
+
Used to invoke a descriptor without going through attribute lookup on the
|
|
2419
|
+
object, since an AttributeError raised inside a descriptor is
|
|
2420
|
+
indistinguishable from a missing attribute to the attribute machinery,
|
|
2421
|
+
which clears it and dispatches to ``__getattr__``.
|
|
2422
|
+
"""
|
|
2423
|
+
for klass in cls.__mro__:
|
|
2424
|
+
if attr in klass.__dict__:
|
|
2425
|
+
return klass.__dict__[attr]
|
|
2426
|
+
return None
|
|
2427
|
+
|
|
2428
|
+
|
|
2414
2429
|
class Parameters:
|
|
2415
2430
|
"""
|
|
2416
2431
|
Object that holds the ``.param`` namespace and implementation of
|
|
@@ -2562,9 +2577,27 @@ class Parameters:
|
|
|
2562
2577
|
if cls is None: # Class not initialized
|
|
2563
2578
|
raise AttributeError
|
|
2564
2579
|
|
|
2565
|
-
|
|
2580
|
+
ns_type = type(self_)
|
|
2581
|
+
|
|
2582
|
+
# Read the cached parameters from _param__private rather than from the
|
|
2583
|
+
# _cls_parameters property: an AttributeError raised by that property is
|
|
2584
|
+
# dispatched to this method, so accessing it as an attribute here would
|
|
2585
|
+
# recurse. When the cache is empty the property is invoked directly as a
|
|
2586
|
+
# descriptor instead, which bypasses that dispatch.
|
|
2587
|
+
params = cls._param__private.params
|
|
2588
|
+
if not params:
|
|
2589
|
+
params = _find_descriptor(ns_type, '_cls_parameters').__get__(self_, ns_type)
|
|
2590
|
+
if attr in params:
|
|
2566
2591
|
return self_.__getitem__(attr)
|
|
2567
|
-
|
|
2592
|
+
|
|
2593
|
+
# attr is not a Parameter, so if it does exist on this class the
|
|
2594
|
+
# AttributeError we are handling was raised inside its descriptor.
|
|
2595
|
+
# Invoking it again surfaces that error instead of masking it.
|
|
2596
|
+
descriptor = _find_descriptor(ns_type, attr)
|
|
2597
|
+
if descriptor is not None:
|
|
2598
|
+
return descriptor.__get__(self_, ns_type)
|
|
2599
|
+
|
|
2600
|
+
if self_.self is None:
|
|
2568
2601
|
raise AttributeError(f"type object '{self_.cls.__name__}.param' has no attribute {attr!r}")
|
|
2569
2602
|
else:
|
|
2570
2603
|
raise AttributeError(f"'{self_.cls.__name__}.param' object has no attribute {attr!r}")
|
|
@@ -2710,7 +2743,10 @@ class Parameters:
|
|
|
2710
2743
|
if new_val is Skip or new_val is Undefined:
|
|
2711
2744
|
continue
|
|
2712
2745
|
elif is_async:
|
|
2713
|
-
|
|
2746
|
+
generation = self_._schedule_async_ref(pname)
|
|
2747
|
+
async_executor(partial(
|
|
2748
|
+
self_._async_ref, pname, t.cast("t.Awaitable[t.Any]", new_val), generation
|
|
2749
|
+
))
|
|
2714
2750
|
continue
|
|
2715
2751
|
|
|
2716
2752
|
updates[pname] = new_val
|
|
@@ -2731,39 +2767,85 @@ class Parameters:
|
|
|
2731
2767
|
except Skip:
|
|
2732
2768
|
value = Undefined
|
|
2733
2769
|
if is_async and pobj.name:
|
|
2734
|
-
|
|
2770
|
+
generation = self_._schedule_async_ref(pobj.name)
|
|
2771
|
+
async_executor(partial(
|
|
2772
|
+
self_._async_ref, pobj.name, t.cast("t.Awaitable[t.Any]", value), generation
|
|
2773
|
+
))
|
|
2735
2774
|
value = None
|
|
2736
2775
|
return ref, deps, value, is_async
|
|
2737
2776
|
|
|
2738
|
-
|
|
2777
|
+
def _schedule_async_ref(self_, pname: str) -> int:
|
|
2778
|
+
"""
|
|
2779
|
+
Record that an asynchronous reference resolution is about to be
|
|
2780
|
+
scheduled and return the generation identifying it.
|
|
2781
|
+
|
|
2782
|
+
The generation is bumped synchronously, before the task is handed to
|
|
2783
|
+
the executor, so that the reference reads as unsettled from the moment
|
|
2784
|
+
it is superseded rather than only once the task starts running.
|
|
2785
|
+
"""
|
|
2786
|
+
if self_.self is None:
|
|
2787
|
+
return 0
|
|
2788
|
+
private = self_.self._param__private
|
|
2789
|
+
private.async_ref_scheduled[pname] += 1
|
|
2790
|
+
return private.async_ref_scheduled[pname]
|
|
2791
|
+
|
|
2792
|
+
def _settle_async_ref(self_, pname: str, generation: int):
|
|
2793
|
+
"""
|
|
2794
|
+
Record that the resolution identified by ``generation`` produced a
|
|
2795
|
+
value, or gave up on producing one.
|
|
2796
|
+
|
|
2797
|
+
A superseded task settling late must not mark the reference settled for
|
|
2798
|
+
the generation that superseded it, so the generation is recorded rather
|
|
2799
|
+
than cleared. Generators settle on every value they yield, so a
|
|
2800
|
+
reference is unsettled only until its next value arrives, not until the
|
|
2801
|
+
generator is exhausted.
|
|
2802
|
+
"""
|
|
2803
|
+
if self_.self is None or not generation:
|
|
2804
|
+
return
|
|
2805
|
+
settled = self_.self._param__private.async_ref_settled
|
|
2806
|
+
settled[pname] = max(settled[pname], generation)
|
|
2807
|
+
|
|
2808
|
+
def _awaiting_ref(self_, pname: str) -> bool:
|
|
2809
|
+
"""Whether an asynchronous reference has not yet produced a value."""
|
|
2810
|
+
if self_.self is None:
|
|
2811
|
+
return False
|
|
2812
|
+
private = self_.self._param__private
|
|
2813
|
+
return private.async_ref_scheduled[pname] != private.async_ref_settled[pname]
|
|
2814
|
+
|
|
2815
|
+
async def _async_ref(self_, pname: str, awaitable: t.Awaitable[t.Any], generation: int = 0):
|
|
2739
2816
|
if self_.self is None:
|
|
2740
2817
|
return
|
|
2741
2818
|
if not self_.self._param__private.initialized:
|
|
2742
|
-
async_executor(partial(self_._async_ref, pname, awaitable))
|
|
2819
|
+
async_executor(partial(self_._async_ref, pname, awaitable, generation))
|
|
2743
2820
|
return
|
|
2744
2821
|
|
|
2745
2822
|
import asyncio
|
|
2746
2823
|
current_task = asyncio.current_task()
|
|
2747
2824
|
running_task = self_.self._param__private.async_refs.get(pname)
|
|
2748
|
-
if running_task is
|
|
2825
|
+
if running_task is not current_task:
|
|
2826
|
+
if running_task is not None:
|
|
2827
|
+
running_task.cancel()
|
|
2749
2828
|
self_.self._param__private.async_refs[pname] = current_task
|
|
2750
|
-
elif current_task is not running_task:
|
|
2751
|
-
self_.self._param__private.async_refs[pname].cancel()
|
|
2752
2829
|
try:
|
|
2753
2830
|
if isinstance(awaitable, types.AsyncGeneratorType):
|
|
2754
2831
|
async for new_obj in awaitable:
|
|
2755
2832
|
with _syncing(self_.self, (pname,)):
|
|
2756
2833
|
self_.update({pname: new_obj})
|
|
2834
|
+
self_._settle_async_ref(pname, generation)
|
|
2757
2835
|
else:
|
|
2758
2836
|
with _syncing(self_.self, (pname,)):
|
|
2759
2837
|
try:
|
|
2760
2838
|
self_.update({pname: await awaitable})
|
|
2761
2839
|
except Skip:
|
|
2762
2840
|
pass
|
|
2841
|
+
self_._settle_async_ref(pname, generation)
|
|
2763
2842
|
finally:
|
|
2764
|
-
|
|
2765
|
-
if
|
|
2766
|
-
|
|
2843
|
+
self_._settle_async_ref(pname, generation)
|
|
2844
|
+
# Ensure we clean up but only if the task matches the current task,
|
|
2845
|
+
# i.e. only the resolution that still owns the reference clears it.
|
|
2846
|
+
async_refs = self_.self._param__private.async_refs
|
|
2847
|
+
if pname in async_refs and async_refs[pname] is current_task:
|
|
2848
|
+
del async_refs[pname]
|
|
2767
2849
|
|
|
2768
2850
|
@classmethod
|
|
2769
2851
|
def _changed(cls, event):
|
|
@@ -3140,18 +3222,21 @@ class Parameters:
|
|
|
3140
3222
|
pdict = private.params
|
|
3141
3223
|
if pdict:
|
|
3142
3224
|
if private.params_to_deepcopy is None or private.params_to_ref is None or private.params_with_default_factory is None:
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3225
|
+
to_deepcopy = []
|
|
3226
|
+
to_ref = []
|
|
3227
|
+
with_default_factory = []
|
|
3146
3228
|
for pname, pobj in pdict.items():
|
|
3147
3229
|
if pname == 'name':
|
|
3148
3230
|
continue
|
|
3149
3231
|
if pobj.default_factory is not None:
|
|
3150
|
-
|
|
3232
|
+
with_default_factory.append((pname, pobj))
|
|
3151
3233
|
elif pobj.instantiate:
|
|
3152
|
-
|
|
3234
|
+
to_deepcopy.append(pobj)
|
|
3153
3235
|
elif pobj.constant:
|
|
3154
|
-
|
|
3236
|
+
to_ref.append(pobj)
|
|
3237
|
+
private.params_to_deepcopy = to_deepcopy
|
|
3238
|
+
private.params_to_ref = to_ref
|
|
3239
|
+
private.params_with_default_factory = with_default_factory
|
|
3155
3240
|
return pdict
|
|
3156
3241
|
|
|
3157
3242
|
paramdict = {}
|
|
@@ -5603,6 +5688,8 @@ class _InstancePrivate:
|
|
|
5603
5688
|
'dynamic_watchers',
|
|
5604
5689
|
'params',
|
|
5605
5690
|
'async_refs',
|
|
5691
|
+
'async_ref_scheduled',
|
|
5692
|
+
'async_ref_settled',
|
|
5606
5693
|
'refs',
|
|
5607
5694
|
'ref_watchers',
|
|
5608
5695
|
'syncing',
|
|
@@ -5616,6 +5703,8 @@ class _InstancePrivate:
|
|
|
5616
5703
|
dynamic_watchers: defaultdict[str, list[Watcher]]
|
|
5617
5704
|
params: dict[str, Parameter]
|
|
5618
5705
|
async_refs: dict[str, t.Any]
|
|
5706
|
+
async_ref_scheduled: defaultdict[str, int]
|
|
5707
|
+
async_ref_settled: defaultdict[str, int]
|
|
5619
5708
|
refs: dict[str, t.Any]
|
|
5620
5709
|
ref_watchers: list[tuple[tuple[str, ...], Watcher]]
|
|
5621
5710
|
syncing: set[str]
|
|
@@ -5646,6 +5735,8 @@ class _InstancePrivate:
|
|
|
5646
5735
|
}
|
|
5647
5736
|
self.ref_watchers = []
|
|
5648
5737
|
self.async_refs = {}
|
|
5738
|
+
self.async_ref_scheduled = defaultdict(int)
|
|
5739
|
+
self.async_ref_settled = defaultdict(int)
|
|
5649
5740
|
self.parameters_state = parameters_state
|
|
5650
5741
|
self.dynamic_watchers = defaultdict(list, dynamic_watchers or ())
|
|
5651
5742
|
self.params = {} if params is None else params
|
|
@@ -6320,7 +6411,7 @@ class ParameterizedFunction(Parameterized, t.Generic[_P, _R]):
|
|
|
6320
6411
|
params.pop('name')
|
|
6321
6412
|
cls = self_or_cls.__class__
|
|
6322
6413
|
|
|
6323
|
-
inst = Parameterized.__new__(cls)
|
|
6414
|
+
inst = Parameterized.__new__(cls) # pyrefly: ignore[bad-argument-type]
|
|
6324
6415
|
Parameterized.__init__(inst, **params)
|
|
6325
6416
|
if 'name' in params:
|
|
6326
6417
|
setattr(inst, "__name__", params['name'])
|
|
@@ -2647,7 +2647,7 @@ class Selector(SelectorBase, _SignatureSelector[_T]):
|
|
|
2647
2647
|
object.__setattr__(self, 'check_on_set', check_on_set)
|
|
2648
2648
|
|
|
2649
2649
|
instantiate = params.pop("instantiate", Undefined)
|
|
2650
|
-
params["instantiate"] = False if instantiate is Undefined else instantiate # pyrefly: ignore[bad-
|
|
2650
|
+
params["instantiate"] = False if instantiate is Undefined else instantiate # pyrefly: ignore[bad-assignment]
|
|
2651
2651
|
super().__init__(default=default, **params)
|
|
2652
2652
|
# Required as Parameter sets allow_None=True if default is None
|
|
2653
2653
|
if allow_None is Undefined:
|
|
@@ -2846,7 +2846,7 @@ class FileSelector(Selector[_T]):
|
|
|
2846
2846
|
self.default = self.objects[0] if self.objects else None
|
|
2847
2847
|
|
|
2848
2848
|
def get_range(self) -> dict[str, str | PathLike]:
|
|
2849
|
-
return _abbreviate_paths(self.path,super().get_range())
|
|
2849
|
+
return _abbreviate_paths(self.path, super().get_range())
|
|
2850
2850
|
|
|
2851
2851
|
|
|
2852
2852
|
class ListSelector(Selector):
|
|
@@ -3731,7 +3731,7 @@ class List(Parameter[_T]):
|
|
|
3731
3731
|
if is_instance and not isinstance(v, item_type):
|
|
3732
3732
|
err_kind = "instances"
|
|
3733
3733
|
obj_display = lambda v: type(v)
|
|
3734
|
-
elif not is_instance and (
|
|
3734
|
+
elif not is_instance and (not isinstance(v, type) or not issubclass(v, item_type)):
|
|
3735
3735
|
err_kind = "subclasses"
|
|
3736
3736
|
if err_kind:
|
|
3737
3737
|
raise TypeError(
|