param 2.0.1rc2__tar.gz → 2.0.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.
Files changed (68) hide show
  1. {param-2.0.1rc2 → param-2.0.2}/PKG-INFO +3 -3
  2. {param-2.0.1rc2 → param-2.0.2}/README.md +1 -1
  3. {param-2.0.1rc2 → param-2.0.2}/param/__init__.py +17 -5
  4. {param-2.0.1rc2 → param-2.0.2}/param/_utils.py +10 -12
  5. {param-2.0.1rc2 → param-2.0.2}/param/_version.py +2 -2
  6. {param-2.0.1rc2 → param-2.0.2}/param/parameterized.py +38 -35
  7. {param-2.0.1rc2 → param-2.0.2}/pyproject.toml +1 -1
  8. {param-2.0.1rc2 → param-2.0.2}/tests/testutils.py +29 -1
  9. {param-2.0.1rc2 → param-2.0.2}/.gitignore +0 -0
  10. {param-2.0.1rc2 → param-2.0.2}/LICENSE.txt +0 -0
  11. {param-2.0.1rc2 → param-2.0.2}/numbergen/__init__.py +0 -0
  12. {param-2.0.1rc2 → param-2.0.2}/param/depends.py +0 -0
  13. {param-2.0.1rc2 → param-2.0.2}/param/display.py +0 -0
  14. {param-2.0.1rc2 → param-2.0.2}/param/ipython.py +0 -0
  15. {param-2.0.1rc2 → param-2.0.2}/param/parameters.py +0 -0
  16. {param-2.0.1rc2 → param-2.0.2}/param/reactive.py +0 -0
  17. {param-2.0.1rc2 → param-2.0.2}/param/serializer.py +0 -0
  18. {param-2.0.1rc2 → param-2.0.2}/param/version.py +0 -0
  19. {param-2.0.1rc2 → param-2.0.2}/tests/__init__.py +0 -0
  20. {param-2.0.1rc2 → param-2.0.2}/tests/conftest.py +0 -0
  21. {param-2.0.1rc2 → param-2.0.2}/tests/testaddparameter.py +0 -0
  22. {param-2.0.1rc2 → param-2.0.2}/tests/testbind.py +0 -0
  23. {param-2.0.1rc2 → param-2.0.2}/tests/testbooleanparam.py +0 -0
  24. {param-2.0.1rc2 → param-2.0.2}/tests/testbytesparam.py +0 -0
  25. {param-2.0.1rc2 → param-2.0.2}/tests/testcalendardateparam.py +0 -0
  26. {param-2.0.1rc2 → param-2.0.2}/tests/testcalendardaterangeparam.py +0 -0
  27. {param-2.0.1rc2 → param-2.0.2}/tests/testcallable.py +0 -0
  28. {param-2.0.1rc2 → param-2.0.2}/tests/testclassselector.py +0 -0
  29. {param-2.0.1rc2 → param-2.0.2}/tests/testcolorparameter.py +0 -0
  30. {param-2.0.1rc2 → param-2.0.2}/tests/testcomparator.py +0 -0
  31. {param-2.0.1rc2 → param-2.0.2}/tests/testcompositeparams.py +0 -0
  32. {param-2.0.1rc2 → param-2.0.2}/tests/testcustomparam.py +0 -0
  33. {param-2.0.1rc2 → param-2.0.2}/tests/testdateparam.py +0 -0
  34. {param-2.0.1rc2 → param-2.0.2}/tests/testdaterangeparam.py +0 -0
  35. {param-2.0.1rc2 → param-2.0.2}/tests/testdefaults.py +0 -0
  36. {param-2.0.1rc2 → param-2.0.2}/tests/testdeprecations.py +0 -0
  37. {param-2.0.1rc2 → param-2.0.2}/tests/testdynamicparams.py +0 -0
  38. {param-2.0.1rc2 → param-2.0.2}/tests/testfiledeserialization.py +0 -0
  39. {param-2.0.1rc2 → param-2.0.2}/tests/testfileselector.py +0 -0
  40. {param-2.0.1rc2 → param-2.0.2}/tests/testipythonmagic.py +0 -0
  41. {param-2.0.1rc2 → param-2.0.2}/tests/testjsonserialization.py +0 -0
  42. {param-2.0.1rc2 → param-2.0.2}/tests/testlist.py +0 -0
  43. {param-2.0.1rc2 → param-2.0.2}/tests/testlistselector.py +0 -0
  44. {param-2.0.1rc2 → param-2.0.2}/tests/testmultifileselector.py +0 -0
  45. {param-2.0.1rc2 → param-2.0.2}/tests/testnumbergen.py +0 -0
  46. {param-2.0.1rc2 → param-2.0.2}/tests/testnumberparameter.py +0 -0
  47. {param-2.0.1rc2 → param-2.0.2}/tests/testnumpy.py +0 -0
  48. {param-2.0.1rc2 → param-2.0.2}/tests/testobjectselector.py +0 -0
  49. {param-2.0.1rc2 → param-2.0.2}/tests/testpandas.py +0 -0
  50. {param-2.0.1rc2 → param-2.0.2}/tests/testparamdepends.py +0 -0
  51. {param-2.0.1rc2 → param-2.0.2}/tests/testparameterizedobject.py +0 -0
  52. {param-2.0.1rc2 → param-2.0.2}/tests/testparameterizedrepr.py +0 -0
  53. {param-2.0.1rc2 → param-2.0.2}/tests/testparamoutput.py +0 -0
  54. {param-2.0.1rc2 → param-2.0.2}/tests/testparamunion.py +0 -0
  55. {param-2.0.1rc2 → param-2.0.2}/tests/testpathparam.py +0 -0
  56. {param-2.0.1rc2 → param-2.0.2}/tests/testpickle.py +0 -0
  57. {param-2.0.1rc2 → param-2.0.2}/tests/testrangeparameter.py +0 -0
  58. {param-2.0.1rc2 → param-2.0.2}/tests/testreactive.py +0 -0
  59. {param-2.0.1rc2 → param-2.0.2}/tests/testrefs.py +0 -0
  60. {param-2.0.1rc2 → param-2.0.2}/tests/testreprhtml.py +0 -0
  61. {param-2.0.1rc2 → param-2.0.2}/tests/testselector.py +0 -0
  62. {param-2.0.1rc2 → param-2.0.2}/tests/testsignatures.py +0 -0
  63. {param-2.0.1rc2 → param-2.0.2}/tests/teststringparam.py +0 -0
  64. {param-2.0.1rc2 → param-2.0.2}/tests/testtimedependent.py +0 -0
  65. {param-2.0.1rc2 → param-2.0.2}/tests/testtupleparam.py +0 -0
  66. {param-2.0.1rc2 → param-2.0.2}/tests/testversion.py +0 -0
  67. {param-2.0.1rc2 → param-2.0.2}/tests/testwatch.py +0 -0
  68. {param-2.0.1rc2 → param-2.0.2}/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: param
3
- Version: 2.0.1rc2
3
+ Version: 2.0.2
4
4
  Summary: Make your Python code clearer and more reliable by declaring Parameters.
5
5
  Project-URL: Homepage, https://param.holoviz.org/
6
6
  Project-URL: Tracker, https://github.com/holoviz/param/issues
@@ -31,7 +31,7 @@ Requires-Dist: param[doc]; extra == 'all'
31
31
  Requires-Dist: param[lint]; extra == 'all'
32
32
  Requires-Dist: param[tests-full]; extra == 'all'
33
33
  Provides-Extra: doc
34
- Requires-Dist: nbsite==0.8.2; extra == 'doc'
34
+ Requires-Dist: nbsite==0.8.4; extra == 'doc'
35
35
  Requires-Dist: param[examples]; extra == 'doc'
36
36
  Requires-Dist: sphinx-remove-toctrees; extra == 'doc'
37
37
  Provides-Extra: examples
@@ -74,7 +74,7 @@ Description-Content-Type: text/markdown
74
74
 
75
75
  | | |
76
76
  | --- | --- |
77
- | Build Status | [![Linux/MacOS/Windows Build Status](https://github.com/holoviz/param/workflows/pytest/badge.svg)](https://github.com/holoviz/param/actions/workflows/test.yml)
77
+ | Build Status | [![Linux/MacOS/Windows Build Status](https://github.com/holoviz/param/workflows/tests/badge.svg)](https://github.com/holoviz/param/actions/workflows/test.yaml)
78
78
  | Coverage | [![codecov](https://codecov.io/gh/holoviz/param/branch/main/graph/badge.svg)](https://codecov.io/gh/holoviz/param) ||
79
79
  | Latest dev release | [![Github tag](https://img.shields.io/github/v/tag/holoviz/param.svg?label=tag&colorB=11ccbb)](https://github.com/holoviz/param/tags) [![dev-site](https://img.shields.io/website-up-down-green-red/https/holoviz-dev.github.io/param.svg?label=dev%20website)](https://holoviz-dev.github.io/param/) |
80
80
  | Latest release | [![Github release](https://img.shields.io/github/release/holoviz/param.svg?label=tag&colorB=11ccbb)](https://github.com/holoviz/param/releases) [![PyPI version](https://img.shields.io/pypi/v/param.svg?colorB=cc77dd)](https://pypi.python.org/pypi/param) [![param version](https://img.shields.io/conda/v/pyviz/param.svg?colorB=4488ff&style=flat)](https://anaconda.org/pyviz/param) [![conda-forge version](https://img.shields.io/conda/v/conda-forge/param.svg?label=conda%7Cconda-forge&colorB=4488ff)](https://anaconda.org/conda-forge/param) [![defaults version](https://img.shields.io/conda/v/anaconda/param.svg?label=conda%7Cdefaults&style=flat&colorB=4488ff)](https://anaconda.org/anaconda/param) |
@@ -2,7 +2,7 @@
2
2
 
3
3
  | | |
4
4
  | --- | --- |
5
- | Build Status | [![Linux/MacOS/Windows Build Status](https://github.com/holoviz/param/workflows/pytest/badge.svg)](https://github.com/holoviz/param/actions/workflows/test.yml)
5
+ | Build Status | [![Linux/MacOS/Windows Build Status](https://github.com/holoviz/param/workflows/tests/badge.svg)](https://github.com/holoviz/param/actions/workflows/test.yaml)
6
6
  | Coverage | [![codecov](https://codecov.io/gh/holoviz/param/branch/main/graph/badge.svg)](https://codecov.io/gh/holoviz/param) ||
7
7
  | Latest dev release | [![Github tag](https://img.shields.io/github/v/tag/holoviz/param.svg?label=tag&colorB=11ccbb)](https://github.com/holoviz/param/tags) [![dev-site](https://img.shields.io/website-up-down-green-red/https/holoviz-dev.github.io/param.svg?label=dev%20website)](https://holoviz-dev.github.io/param/) |
8
8
  | Latest release | [![Github release](https://img.shields.io/github/release/holoviz/param.svg?label=tag&colorB=11ccbb)](https://github.com/holoviz/param/releases) [![PyPI version](https://img.shields.io/pypi/v/param.svg?colorB=cc77dd)](https://pypi.python.org/pypi/param) [![param version](https://img.shields.io/conda/v/pyviz/param.svg?colorB=4488ff&style=flat)](https://anaconda.org/pyviz/param) [![conda-forge version](https://img.shields.io/conda/v/conda-forge/param.svg?label=conda%7Cconda-forge&colorB=4488ff)](https://anaconda.org/conda-forge/param) [![defaults version](https://img.shields.io/conda/v/anaconda/param.svg?label=conda%7Cdefaults&style=flat&colorB=4488ff)](https://anaconda.org/anaconda/param) |
@@ -90,11 +90,23 @@ try:
90
90
  except (ImportError, LookupError, FileNotFoundError):
91
91
  # As a fallback, use the version that is hard-coded in the file.
92
92
  try:
93
- from ._version import __version__
94
- except ModuleNotFoundError:
95
- # The user is probably trying to run this without having installed
96
- # the package.
97
- __version__ = "0.0.0+unknown"
93
+ # __version__ was added in _version in setuptools-scm 7.0.0, we rely on
94
+ # the hopefully stable version variable.
95
+ from ._version import version as __version__
96
+ except (ModuleNotFoundError, ImportError):
97
+ # Either _version doesn't exist (ModuleNotFoundError) or version isn't
98
+ # in _version (ImportError). ModuleNotFoundError is a subclass of
99
+ # ImportError, let's be explicit anyway.
100
+
101
+ # Try something else:
102
+ from importlib.metadata import version as mversion, PackageNotFoundError
103
+
104
+ try:
105
+ __version__ = mversion("param")
106
+ except PackageNotFoundError:
107
+ # The user is probably trying to run this without having installed
108
+ # the package.
109
+ __version__ = "0.0.0+unknown"
98
110
 
99
111
  #: Top-level object to allow messaging not tied to a particular
100
112
  #: Parameterized object, as in 'param.main.warning("Invalid option")'.
@@ -208,18 +208,16 @@ def full_groupby(l, key=lambda x: x):
208
208
 
209
209
  def iscoroutinefunction(function):
210
210
  """
211
- Whether the function is an asynchronous coroutine function.
212
- """
213
- if not hasattr(inspect, 'iscoroutinefunction'):
214
- return False
215
- import asyncio
216
- try:
217
- return (
218
- inspect.isasyncgenfunction(function) or
219
- asyncio.iscoroutinefunction(function)
220
- )
221
- except AttributeError:
222
- return False
211
+ Whether the function is an asynchronous generator or a coroutine.
212
+ """
213
+ # Partial unwrapping not required starting from Python 3.11.0
214
+ # See https://github.com/holoviz/param/pull/894#issuecomment-1867084447
215
+ while isinstance(function, functools.partial):
216
+ function = function.func
217
+ return (
218
+ inspect.isasyncgenfunction(function) or
219
+ inspect.iscoroutinefunction(function)
220
+ )
223
221
 
224
222
 
225
223
  def flatten(line):
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '2.0.1rc2'
16
- __version_tuple__ = version_tuple = (2, 0, 1)
15
+ __version__ = version = '2.0.2'
16
+ __version_tuple__ = version_tuple = (2, 0, 2)
@@ -1849,24 +1849,25 @@ class Parameters:
1849
1849
  Returns the class or instance parameter
1850
1850
  """
1851
1851
  inst = self_.self
1852
- params = self_ if inst is None else inst.param
1853
- p = params.objects(False)[key]
1854
- return p if inst is None else _instantiated_parameter(inst, p)
1852
+ if inst is None:
1853
+ return self_._cls_parameters[key]
1854
+ p = self_.objects(instance=False)[key]
1855
+ return _instantiated_parameter(inst, p)
1855
1856
 
1856
1857
  def __dir__(self_):
1857
1858
  """
1858
1859
  Adds parameters to dir
1859
1860
  """
1860
- return super().__dir__() + list(self_)
1861
+ return super().__dir__() + list(self_._cls_parameters)
1861
1862
 
1862
1863
  def __iter__(self_):
1863
1864
  """
1864
1865
  Iterates over the parameters on this object.
1865
1866
  """
1866
- yield from self_.objects(instance=False)
1867
+ yield from self_._cls_parameters
1867
1868
 
1868
1869
  def __contains__(self_, param):
1869
- return param in list(self_)
1870
+ return param in self_._cls_parameters
1870
1871
 
1871
1872
  def __getattr__(self_, attr):
1872
1873
  """
@@ -1876,12 +1877,7 @@ class Parameters:
1876
1877
  if cls is None: # Class not initialized
1877
1878
  raise AttributeError
1878
1879
 
1879
- params = list(cls._param__private.params)
1880
- if not params:
1881
- params = [n for class_ in classlist(cls) for n, v in class_.__dict__.items()
1882
- if isinstance(v, Parameter)]
1883
-
1884
- if attr in params:
1880
+ if attr in self_._cls_parameters:
1885
1881
  return self_.__getitem__(attr)
1886
1882
  elif self_.self is None:
1887
1883
  raise AttributeError(f"type object '{self_.cls.__name__}.param' has no attribute {attr!r}")
@@ -1914,7 +1910,8 @@ class Parameters:
1914
1910
  ## Deepcopy all 'instantiate=True' parameters
1915
1911
  params_to_deepcopy = {}
1916
1912
  params_to_ref = {}
1917
- for pname, p in self_.objects(instance=False).items():
1913
+ objects = self_._cls_parameters
1914
+ for pname, p in objects.items():
1918
1915
  if p.instantiate and pname != "name":
1919
1916
  params_to_deepcopy[pname] = p
1920
1917
  elif p.constant and pname != 'name':
@@ -1927,7 +1924,6 @@ class Parameters:
1927
1924
 
1928
1925
  ## keyword arg setting
1929
1926
  deps, refs = {}, {}
1930
- objects = self.param.objects(instance=False)
1931
1927
  for name, val in params.items():
1932
1928
  desc = self_.cls.get_param_descriptor(name)[0] # pylint: disable-msg=E1101
1933
1929
  if not desc:
@@ -2235,8 +2231,8 @@ class Parameters:
2235
2231
  # would need to handle the params() cache as well
2236
2232
  # (which is tricky but important for startup speed).
2237
2233
  cls = self_.cls
2238
- type.__setattr__(cls,param_name,param_obj)
2239
- ParameterizedMetaclass._initialize_parameter(cls,param_name,param_obj)
2234
+ type.__setattr__(cls, param_name, param_obj)
2235
+ ParameterizedMetaclass._initialize_parameter(cls, param_name, param_obj)
2240
2236
  # delete cached params()
2241
2237
  cls._param__private.params.clear()
2242
2238
 
@@ -2352,6 +2348,31 @@ class Parameters:
2352
2348
  (self_or_cls.name))
2353
2349
  return self_.update(kwargs)
2354
2350
 
2351
+ @property
2352
+ def _cls_parameters(self_):
2353
+ """
2354
+ Class parameters are cached because they are accessed often,
2355
+ and parameters are rarely added (and cannot be deleted)
2356
+ """
2357
+ cls = self_.cls
2358
+ pdict = cls._param__private.params
2359
+ if pdict:
2360
+ return pdict
2361
+
2362
+ paramdict = {}
2363
+ for class_ in classlist(cls):
2364
+ for name, val in class_.__dict__.items():
2365
+ if isinstance(val, Parameter):
2366
+ paramdict[name] = val
2367
+
2368
+ # We only want the cache to be visible to the cls on which
2369
+ # params() is called, so we mangle the name ourselves at
2370
+ # runtime (if we were to mangle it now, it would be
2371
+ # _Parameterized.__params for all classes).
2372
+ # cls._param__private.params[f'_{cls.__name__}__params'] = paramdict
2373
+ cls._param__private.params = paramdict
2374
+ return paramdict
2375
+
2355
2376
  def objects(self_, instance=True):
2356
2377
  """
2357
2378
  Returns the Parameters of this instance or class
@@ -2376,25 +2397,7 @@ class Parameters:
2376
2397
  stacklevel=2,
2377
2398
  )
2378
2399
 
2379
- cls = self_.cls
2380
- # We cache the parameters because this method is called often,
2381
- # and parameters are rarely added (and cannot be deleted)
2382
- pdict = cls._param__private.params
2383
- if not pdict:
2384
- paramdict = {}
2385
- for class_ in classlist(cls):
2386
- for name, val in class_.__dict__.items():
2387
- if isinstance(val, Parameter):
2388
- paramdict[name] = val
2389
-
2390
- # We only want the cache to be visible to the cls on which
2391
- # params() is called, so we mangle the name ourselves at
2392
- # runtime (if we were to mangle it now, it would be
2393
- # _Parameterized.__params for all classes).
2394
- # cls._param__private.params[f'_{cls.__name__}__params'] = paramdict
2395
- cls._param__private.params = paramdict
2396
- pdict = paramdict
2397
-
2400
+ pdict = self_._cls_parameters
2398
2401
  if instance and self_.self is not None:
2399
2402
  if instance == 'existing':
2400
2403
  if getattr(self_.self._param__private, 'initialized', False) and self_.self._param__private.params:
@@ -41,7 +41,7 @@ examples = [
41
41
  ]
42
42
  doc = [
43
43
  "param[examples]",
44
- "nbsite ==0.8.2",
44
+ "nbsite ==0.8.4",
45
45
  "sphinx-remove-toctrees",
46
46
  ]
47
47
  tests = [
@@ -1,12 +1,14 @@
1
1
  import datetime as dt
2
2
  import os
3
3
 
4
+ from functools import partial
5
+
4
6
  import param
5
7
  import pytest
6
8
 
7
9
  from param import guess_param_types, resolve_path
8
10
  from param.parameterized import bothmethod
9
- from param._utils import _is_mutable_container
11
+ from param._utils import _is_mutable_container, iscoroutinefunction
10
12
 
11
13
 
12
14
  try:
@@ -393,3 +395,29 @@ def test_error_prefix_set_instance():
393
395
  )
394
396
  def test__is_mutable_container(obj, ismutable):
395
397
  assert _is_mutable_container(obj) is ismutable
398
+
399
+
400
+ async def coro():
401
+ return
402
+
403
+
404
+ def test_iscoroutinefunction_coroutine():
405
+ assert iscoroutinefunction(coro)
406
+
407
+
408
+ def test_iscoroutinefunction_partial_coroutine():
409
+ pcoro = partial(partial(coro))
410
+ assert iscoroutinefunction(pcoro)
411
+
412
+
413
+ async def agen():
414
+ yield
415
+
416
+
417
+ def test_iscoroutinefunction_asyncgen():
418
+ assert iscoroutinefunction(agen)
419
+
420
+
421
+ def test_iscoroutinefunction_partial_asyncgen():
422
+ pagen = partial(partial(agen))
423
+ assert iscoroutinefunction(pagen)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes