decorator 5.1.1__py3-none-any.whl → 5.2.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,14 @@
1
- Copyright (c) 2005-2018, Michele Simionato
1
+ Copyright (c) 2005-2025, Michele Simionato
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
5
5
  modification, are permitted provided that the following conditions are
6
6
  met:
7
7
 
8
- Redistributions of source code must retain the above copyright
8
+ * Redistributions of source code must retain the above copyright
9
9
  notice, this list of conditions and the following disclaimer.
10
- Redistributions in bytecode form must reproduce the above copyright
10
+
11
+ * Redistributions in binary form must reproduce the above copyright
11
12
  notice, this list of conditions and the following disclaimer in
12
13
  the documentation and/or other materials provided with the
13
14
  distribution.
@@ -1,29 +1,28 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: decorator
3
- Version: 5.1.1
3
+ Version: 5.2.0
4
4
  Summary: Decorators for Humans
5
- Home-page: https://github.com/micheles/decorator
6
- Author: Michele Simionato
7
- Author-email: michele.simionato@gmail.com
8
- License: new BSD License
9
- Keywords: decorators generic utility
10
- Platform: All
5
+ Author-email: Michele Simionato <michele.simionato@gmail.com>
6
+ License: BSD-2-Clause
7
+ Keywords: decorators
11
8
  Classifier: Development Status :: 5 - Production/Stable
12
9
  Classifier: Intended Audience :: Developers
13
10
  Classifier: License :: OSI Approved :: BSD License
14
11
  Classifier: Natural Language :: English
15
12
  Classifier: Operating System :: OS Independent
16
13
  Classifier: Programming Language :: Python
17
- Classifier: Programming Language :: Python :: 3.5
18
- Classifier: Programming Language :: Python :: 3.6
19
- Classifier: Programming Language :: Python :: 3.7
20
14
  Classifier: Programming Language :: Python :: 3.8
21
15
  Classifier: Programming Language :: Python :: 3.9
22
16
  Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
23
20
  Classifier: Programming Language :: Python :: Implementation :: CPython
24
21
  Classifier: Topic :: Software Development :: Libraries
25
22
  Classifier: Topic :: Utilities
26
- Requires-Python: >=3.5
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/x-rst
25
+ License-File: LICENSE.txt
27
26
 
28
27
  Decorators for Humans
29
28
  =====================
@@ -109,7 +108,7 @@ operations:
109
108
  result = func(*args, **kw)
110
109
  dt = time.time() - t0
111
110
  if dt > timelimit:
112
- logging.warn('%s took %d seconds', func.__name__, dt)
111
+ logging.warning('%s took %d seconds', func.__name__, dt)
113
112
  else:
114
113
  logging.info('%s took %d seconds', func.__name__, dt)
115
114
  return result
@@ -123,5 +122,3 @@ operations:
123
122
  ...
124
123
 
125
124
  Enjoy!
126
-
127
-
@@ -0,0 +1,7 @@
1
+ decorator.py,sha256=xpjiP2Ajfg6xo0WD2W_rsCI0aDo0CBfVxl0WLtL_Vh4,16912
2
+ decorator-5.2.0.dist-info/LICENSE.txt,sha256=kU7m7Xil78FzvaaY8nCERMqdFA_MQIDGDQUD1A2znaY,1308
3
+ decorator-5.2.0.dist-info/METADATA,sha256=K7pJ6uWpeRYPzx2piRZ8c7LrNKSRVnyPdwJgyjkmzMY,3934
4
+ decorator-5.2.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
5
+ decorator-5.2.0.dist-info/pbr.json,sha256=AL84oUUWQHwkd8OCPhLRo2NJjU5MDdmXMqRHv-posqs,47
6
+ decorator-5.2.0.dist-info/top_level.txt,sha256=Kn6eQjo83ctWxXVyBMOYt0_YpjRjBznKYVuNyuC_DSI,10
7
+ decorator-5.2.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.37.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
decorator.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # ######################### LICENSE ############################ #
2
2
 
3
- # Copyright (c) 2005-2021, Michele Simionato
3
+ # Copyright (c) 2005-2025, Michele Simionato
4
4
  # All rights reserved.
5
5
 
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -37,10 +37,11 @@ import sys
37
37
  import inspect
38
38
  import operator
39
39
  import itertools
40
+ import functools
40
41
  from contextlib import _GeneratorContextManager
41
42
  from inspect import getfullargspec, iscoroutinefunction, isgeneratorfunction
42
43
 
43
- __version__ = '5.1.1'
44
+ __version__ = '5.2.0'
44
45
 
45
46
  DEF = re.compile(r'\s*def\s*([_\w][_\w\d]*)\s*\(')
46
47
  POS = inspect.Parameter.POSITIONAL_OR_KEYWORD
@@ -71,7 +72,7 @@ class FunctionMaker(object):
71
72
  self.name = '_lambda_'
72
73
  self.doc = func.__doc__
73
74
  self.module = func.__module__
74
- if inspect.isroutine(func):
75
+ if inspect.isroutine(func) or isinstance(func, functools.partial):
75
76
  argspec = getfullargspec(func)
76
77
  self.annotations = getattr(func, '__annotations__', {})
77
78
  for a in ('args', 'varargs', 'varkw', 'defaults', 'kwonlyargs',
@@ -214,6 +215,8 @@ def decorate(func, caller, extras=(), kwsyntax=False):
214
215
  does. By default kwsyntax is False and the the arguments are untouched.
215
216
  """
216
217
  sig = inspect.signature(func)
218
+ if isinstance(func, functools.partial):
219
+ func = functools.update_wrapper(func, func.func)
217
220
  if iscoroutinefunction(caller):
218
221
  async def fun(*args, **kw):
219
222
  if not kwsyntax:
@@ -230,6 +233,7 @@ def decorate(func, caller, extras=(), kwsyntax=False):
230
233
  if not kwsyntax:
231
234
  args, kw = fix(args, kw, sig)
232
235
  return caller(func, *(extras + args), **kw)
236
+
233
237
  fun.__name__ = func.__name__
234
238
  fun.__doc__ = func.__doc__
235
239
  fun.__wrapped__ = func
@@ -419,8 +423,8 @@ def dispatch_on(*dispatch_args):
419
423
  """
420
424
  check(types)
421
425
  lst = []
422
- for anc in itertools.product(*ancestors(*types)):
423
- lst.append(tuple(a.__name__ for a in anc))
426
+ for ancs in itertools.product(*ancestors(*types)):
427
+ lst.append(tuple(a.__name__ for a in ancs))
424
428
  return lst
425
429
 
426
430
  def _dispatch(dispatch_args, *args, **kw):
@@ -1,7 +0,0 @@
1
- decorator.py,sha256=el5cAEgoTEpRQN65tOxGhElue-CccMv0xol-J2MwOc0,16752
2
- decorator-5.1.1.dist-info/LICENSE.txt,sha256=_RFmDKvwUyCCxFcGhi-vwpSQfsf44heBgkCkmZgGeC4,1309
3
- decorator-5.1.1.dist-info/METADATA,sha256=XAr2zbYpRxCkcPbsmg1oaiS5ea7mhTq-j-wb0XjuVho,3955
4
- decorator-5.1.1.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
5
- decorator-5.1.1.dist-info/pbr.json,sha256=AL84oUUWQHwkd8OCPhLRo2NJjU5MDdmXMqRHv-posqs,47
6
- decorator-5.1.1.dist-info/top_level.txt,sha256=Kn6eQjo83ctWxXVyBMOYt0_YpjRjBznKYVuNyuC_DSI,10
7
- decorator-5.1.1.dist-info/RECORD,,