decorator 5.1.1__tar.gz → 5.2.1__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.
@@ -3,6 +3,28 @@ HISTORY
3
3
 
4
4
  ## Unreleased
5
5
 
6
+ ## 5.2.1 (2025-02-24)
7
+
8
+ Shiv Krishna Jaiswal suggested how to manage che case of functions
9
+ without __name__.
10
+ Michał Górny contributed a fix for the generation of the source package.
11
+
12
+ ## 5.2.0 (2025-02-22)
13
+
14
+ Changed the build procedure to use pyproject.toml and moved the tests
15
+ outside of the generated wheel/tarball.
16
+
17
+ Added official support for Python 3.11, 3.12, 3.13 (thanks to Hugo van
18
+ Kemenade).
19
+
20
+ Dropped official support for Python < 3.8: the module is
21
+ expected to work on older Python versions, but I cannot test such
22
+ versions on GitHub actions, so I cannot claim that it is officially
23
+ supported.
24
+
25
+ Dafu Wu provided support for decorating partial functions, i.e.
26
+ functions wrapped by functools.partial.
27
+
6
28
  ## 5.1.1 (2022-01-07)
7
29
 
8
30
  Sangwoo Shim contributed a fix so that cythonized functions can be decorated.
@@ -32,7 +54,7 @@ lacking dunder attributes, like `dict.__setitem__`.
32
54
  ## 5.0.7 (2021-04-14)
33
55
 
34
56
  The decorator module was not passing correctly the defaults inside the
35
- `*args` tuple, thanks to Dan Shult for the fix. Also fixed some mispellings
57
+ `*args` tuple, thanks to Dan Shult for the fix. Also fixed some misspellings
36
58
  in the documentation and integrated codespell in the CI, thanks to
37
59
  Christian Clauss.
38
60
 
@@ -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.
@@ -0,0 +1,4 @@
1
+ include README.rst LICENSE.txt CHANGES.md performance.sh
2
+ include src/decorator.py
3
+ include tests/*.py
4
+ graft docs
@@ -0,0 +1,124 @@
1
+ Metadata-Version: 2.2
2
+ Name: decorator
3
+ Version: 5.2.1
4
+ Summary: Decorators for Humans
5
+ Author-email: Michele Simionato <michele.simionato@gmail.com>
6
+ License: BSD-2-Clause
7
+ Keywords: decorators
8
+ Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: BSD License
11
+ Classifier: Natural Language :: English
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
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
20
+ Classifier: Programming Language :: Python :: Implementation :: CPython
21
+ Classifier: Topic :: Software Development :: Libraries
22
+ Classifier: Topic :: Utilities
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/x-rst
25
+ License-File: LICENSE.txt
26
+
27
+ Decorators for Humans
28
+ =====================
29
+
30
+ The goal of the decorator module is to make it easy to define
31
+ signature-preserving function decorators and decorator factories.
32
+ It also includes an implementation of multiple dispatch and other niceties
33
+ (please check the docs). It is released under a two-clauses
34
+ BSD license, i.e. basically you can do whatever you want with it but I am not
35
+ responsible.
36
+
37
+ Installation
38
+ -------------
39
+
40
+ If you are lazy, just perform
41
+
42
+ ``$ pip install decorator``
43
+
44
+ which will install just the module on your system.
45
+
46
+ If you prefer to install the full distribution from source, including
47
+ the documentation, clone the `GitHub repo`_ or download the tarball_, unpack it and run
48
+
49
+ ``$ pip install .``
50
+
51
+ in the main directory, possibly as superuser.
52
+
53
+ .. _tarball: https://pypi.org/project/decorator/#files
54
+ .. _GitHub repo: https://github.com/micheles/decorator
55
+
56
+ Testing
57
+ --------
58
+
59
+ If you have the source code installation you can run the tests with
60
+
61
+ `$ python src/tests/test.py -v`
62
+
63
+ or (if you have setuptools installed)
64
+
65
+ `$ python setup.py test`
66
+
67
+ Notice that you may run into trouble if in your system there
68
+ is an older version of the decorator module; in such a case remove the
69
+ old version. It is safe even to copy the module `decorator.py` over
70
+ an existing one, since we kept backward-compatibility for a long time.
71
+
72
+ Repository
73
+ ---------------
74
+
75
+ The project is hosted on GitHub. You can look at the source here:
76
+
77
+ https://github.com/micheles/decorator
78
+
79
+ Documentation
80
+ ---------------
81
+
82
+ The documentation has been moved to https://github.com/micheles/decorator/blob/master/docs/documentation.md
83
+
84
+ From there you can get a PDF version by simply using the print
85
+ functionality of your browser.
86
+
87
+ Here is the documentation for previous versions of the module:
88
+
89
+ https://github.com/micheles/decorator/blob/4.3.2/docs/tests.documentation.rst
90
+ https://github.com/micheles/decorator/blob/4.2.1/docs/tests.documentation.rst
91
+ https://github.com/micheles/decorator/blob/4.1.2/docs/tests.documentation.rst
92
+ https://github.com/micheles/decorator/blob/4.0.0/documentation.rst
93
+ https://github.com/micheles/decorator/blob/3.4.2/documentation.rst
94
+
95
+ For the impatient
96
+ -----------------
97
+
98
+ Here is an example of how to define a family of decorators tracing slow
99
+ operations:
100
+
101
+ .. code-block:: python
102
+
103
+ from decorator import decorator
104
+
105
+ @decorator
106
+ def warn_slow(func, timelimit=60, *args, **kw):
107
+ t0 = time.time()
108
+ result = func(*args, **kw)
109
+ dt = time.time() - t0
110
+ if dt > timelimit:
111
+ logging.warning('%s took %d seconds', func.__name__, dt)
112
+ else:
113
+ logging.info('%s took %d seconds', func.__name__, dt)
114
+ return result
115
+
116
+ @warn_slow # warn if it takes more than 1 minute
117
+ def preprocess_input_files(inputdir, tempdir):
118
+ ...
119
+
120
+ @warn_slow(timelimit=600) # warn if it takes more than 10 minutes
121
+ def run_calculation(tempdir, outdir):
122
+ ...
123
+
124
+ Enjoy!
@@ -82,7 +82,7 @@ operations:
82
82
  result = func(*args, **kw)
83
83
  dt = time.time() - t0
84
84
  if dt > timelimit:
85
- logging.warn('%s took %d seconds', func.__name__, dt)
85
+ logging.warning('%s took %d seconds', func.__name__, dt)
86
86
  else:
87
87
  logging.info('%s took %d seconds', func.__name__, dt)
88
88
  return result
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-minimal
@@ -0,0 +1,355 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ #
4
+ # decorator documentation build configuration file, created by
5
+ # sphinx-quickstart on Sun Jul 23 17:11:44 2017.
6
+ #
7
+ # This file is execfile()d with the current directory set to its
8
+ # containing dir.
9
+ #
10
+ # Note that not all possible configuration values are present in this
11
+ # autogenerated file.
12
+ #
13
+ # All configuration values have a default; values that are commented out
14
+ # serve to show the default.
15
+
16
+ from decorator import __version__
17
+
18
+ # If extensions (or modules to document with autodoc) are in another directory,
19
+ # add these directories to sys.path here. If the directory is relative to the
20
+ # documentation root, use os.path.abspath to make it absolute, like shown here.
21
+ #sys.path.insert(0, os.path.abspath('.'))
22
+
23
+ # -- General configuration ------------------------------------------------
24
+
25
+ # If your documentation needs a minimal Sphinx version, state it here.
26
+ #needs_sphinx = '1.0'
27
+
28
+ # Add any Sphinx extension module names here, as strings. They can be
29
+ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
30
+ # ones.
31
+ extensions = [
32
+ 'sphinx.ext.viewcode',
33
+ 'myst_parser'
34
+ ]
35
+
36
+ # Add any paths that contain templates here, relative to this directory.
37
+ templates_path = ['_templates']
38
+
39
+ # The suffix(es) of source filenames.
40
+ # You can specify multiple suffix as a list of string:
41
+ # source_suffix = ['.rst', '.md']
42
+ source_suffix = '.rst'
43
+
44
+ # The encoding of source files.
45
+ #source_encoding = 'utf-8-sig'
46
+
47
+ # The master toctree document.
48
+ master_doc = 'index'
49
+
50
+ # General information about the project.
51
+ project = 'decorator'
52
+ copyright = '2005-2020, Michele Simionato'
53
+ author = 'Michele Simionato'
54
+
55
+ # The version info for the project you're documenting, acts as replacement for
56
+ # |version| and |release|, also used in various other places throughout the
57
+ # built documents.
58
+ #
59
+ # The short X.Y version.
60
+ version = release = __version__
61
+ # The full version, including alpha/beta/rc tags.
62
+
63
+ # The language for content autogenerated by Sphinx. Refer to documentation
64
+ # for a list of supported languages.
65
+ #
66
+ # This is also used if you do content translation via gettext catalogs.
67
+ # Usually you set "language" from the command line for these cases.
68
+ language = None
69
+
70
+ # There are two options for replacing |today|: either, you set today to some
71
+ # non-false value, then it is used:
72
+ #today = ''
73
+ # Else, today_fmt is used as the format for a strftime call.
74
+ #today_fmt = '%B %d, %Y'
75
+
76
+ # List of patterns, relative to source directory, that match files and
77
+ # directories to ignore when looking for source files.
78
+ exclude_patterns = ['_build']
79
+
80
+ # The reST default role (used for this markup: `text`) to use for all
81
+ # documents.
82
+ #default_role = None
83
+
84
+ # If true, '()' will be appended to :func: etc. cross-reference text.
85
+ #add_function_parentheses = True
86
+
87
+ # If true, the current module name will be prepended to all description
88
+ # unit titles (such as .. function::).
89
+ #add_module_names = True
90
+
91
+ # If true, sectionauthor and moduleauthor directives will be shown in the
92
+ # output. They are ignored by default.
93
+ #show_authors = False
94
+
95
+ # The name of the Pygments (syntax highlighting) style to use.
96
+ pygments_style = 'sphinx'
97
+
98
+ # A list of ignored prefixes for module index sorting.
99
+ #modindex_common_prefix = []
100
+
101
+ # If true, keep warnings as "system message" paragraphs in the built documents.
102
+ #keep_warnings = False
103
+
104
+ # If true, `todo` and `todoList` produce output, else they produce nothing.
105
+ todo_include_todos = False
106
+
107
+
108
+ # -- Options for HTML output ----------------------------------------------
109
+
110
+ # The theme to use for HTML and HTML Help pages. See the documentation for
111
+ # a list of builtin themes.
112
+ html_theme = 'alabaster'
113
+
114
+ # Theme options are theme-specific and customize the look and feel of a theme
115
+ # further. For a list of options available for each theme, see the
116
+ # documentation.
117
+ #html_theme_options = {}
118
+
119
+ # Add any paths that contain custom themes here, relative to this directory.
120
+ #html_theme_path = []
121
+
122
+ # The name for this set of Sphinx documents. If None, it defaults to
123
+ # "<project> v<release> documentation".
124
+ #html_title = None
125
+
126
+ # A shorter title for the navigation bar. Default is the same as html_title.
127
+ #html_short_title = None
128
+
129
+ # The name of an image file (relative to this directory) to place at the top
130
+ # of the sidebar.
131
+ #html_logo = None
132
+
133
+ # The name of an image file (relative to this directory) to use as a favicon of
134
+ # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
135
+ # pixels large.
136
+ #html_favicon = None
137
+
138
+ # Add any paths that contain custom static files (such as style sheets) here,
139
+ # relative to this directory. They are copied after the builtin static files,
140
+ # so a file named "default.css" will overwrite the builtin "default.css".
141
+ html_static_path = ['_static']
142
+
143
+ # Add any extra paths that contain custom files (such as robots.txt or
144
+ # .htaccess) here, relative to this directory. These files are copied
145
+ # directly to the root of the documentation.
146
+ #html_extra_path = []
147
+
148
+ # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
149
+ # using the given strftime format.
150
+ #html_last_updated_fmt = '%b %d, %Y'
151
+
152
+ # If true, SmartyPants will be used to convert quotes and dashes to
153
+ # typographically correct entities.
154
+ #html_use_smartypants = True
155
+
156
+ # Custom sidebar templates, maps document names to template names.
157
+ #html_sidebars = {}
158
+
159
+ # Additional templates that should be rendered to pages, maps page names to
160
+ # template names.
161
+ #html_additional_pages = {}
162
+
163
+ # If false, no module index is generated.
164
+ #html_domain_indices = True
165
+
166
+ # If false, no index is generated.
167
+ #html_use_index = True
168
+
169
+ # If true, the index is split into individual pages for each letter.
170
+ #html_split_index = False
171
+
172
+ # If true, links to the reST sources are added to the pages.
173
+ #html_show_sourcelink = True
174
+
175
+ # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
176
+ #html_show_sphinx = True
177
+
178
+ # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
179
+ #html_show_copyright = True
180
+
181
+ # If true, an OpenSearch description file will be output, and all pages will
182
+ # contain a <link> tag referring to it. The value of this option must be the
183
+ # base URL from which the finished HTML is served.
184
+ #html_use_opensearch = ''
185
+
186
+ # This is the file name suffix for HTML files (e.g. ".xhtml").
187
+ #html_file_suffix = None
188
+
189
+ # Language to be used for generating the HTML full-text search index.
190
+ # Sphinx supports the following languages:
191
+ # 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
192
+ # 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
193
+ #html_search_language = 'en'
194
+
195
+ # A dictionary with options for the search language support, empty by default.
196
+ # Now only 'ja' uses this config value
197
+ #html_search_options = {'type': 'default'}
198
+
199
+ # The name of a javascript file (relative to the configuration directory) that
200
+ # implements a search results scorer. If empty, the default will be used.
201
+ #html_search_scorer = 'scorer.js'
202
+
203
+ # Output file base name for HTML help builder.
204
+ htmlhelp_basename = 'decoratordoc'
205
+
206
+ # -- Options for LaTeX output ---------------------------------------------
207
+
208
+ latex_elements = {
209
+ # The paper size ('letterpaper' or 'a4paper').
210
+ #'papersize': 'letterpaper',
211
+
212
+ # The font size ('10pt', '11pt' or '12pt').
213
+ #'pointsize': '10pt',
214
+
215
+ # Additional stuff for the LaTeX preamble.
216
+ #'preamble': '',
217
+
218
+ # Latex figure (float) alignment
219
+ #'figure_align': 'htbp',
220
+ }
221
+
222
+ # Grouping the document tree into LaTeX files. List of tuples
223
+ # (source start file, target name, title,
224
+ # author, documentclass [howto, manual, or own class]).
225
+ latex_documents = [
226
+ (master_doc, 'decorator.tex', 'decorator Documentation',
227
+ 'Michele Simionato', 'manual'),
228
+ ]
229
+
230
+ # The name of an image file (relative to this directory) to place at the top of
231
+ # the title page.
232
+ #latex_logo = None
233
+
234
+ # For "manual" documents, if this is true, then toplevel headings are parts,
235
+ # not chapters.
236
+ #latex_use_parts = False
237
+
238
+ # If true, show page references after internal links.
239
+ #latex_show_pagerefs = False
240
+
241
+ # If true, show URL addresses after external links.
242
+ #latex_show_urls = False
243
+
244
+ # Documents to append as an appendix to all manuals.
245
+ #latex_appendices = []
246
+
247
+ # If false, no module index is generated.
248
+ #latex_domain_indices = True
249
+
250
+
251
+ # -- Options for manual page output ---------------------------------------
252
+
253
+ # One entry per manual page. List of tuples
254
+ # (source start file, name, description, authors, manual section).
255
+ man_pages = [
256
+ (master_doc, 'decorator', 'decorator Documentation',
257
+ [author], 1)
258
+ ]
259
+
260
+ # If true, show URL addresses after external links.
261
+ #man_show_urls = False
262
+
263
+
264
+ # -- Options for Texinfo output -------------------------------------------
265
+
266
+ # Grouping the document tree into Texinfo files. List of tuples
267
+ # (source start file, target name, title, author,
268
+ # dir menu entry, description, category)
269
+ texinfo_documents = [
270
+ (master_doc, 'decorator', 'decorator Documentation',
271
+ author, 'decorator', 'One line description of project.',
272
+ 'Miscellaneous'),
273
+ ]
274
+
275
+ # Documents to append as an appendix to all manuals.
276
+ #texinfo_appendices = []
277
+
278
+ # If false, no module index is generated.
279
+ #texinfo_domain_indices = True
280
+
281
+ # How to display URL addresses: 'footnote', 'no', or 'inline'.
282
+ #texinfo_show_urls = 'footnote'
283
+
284
+ # If true, do not generate a @detailmenu in the "Top" node's menu.
285
+ #texinfo_no_detailmenu = False
286
+
287
+
288
+ # -- Options for Epub output ----------------------------------------------
289
+
290
+ # Bibliographic Dublin Core info.
291
+ epub_title = project
292
+ epub_author = author
293
+ epub_publisher = author
294
+ epub_copyright = copyright
295
+
296
+ # The basename for the epub file. It defaults to the project name.
297
+ #epub_basename = project
298
+
299
+ # The HTML theme for the epub output. Since the default themes are not
300
+ # optimized for small screen space, using the same theme for HTML and epub
301
+ # output is usually not wise. This defaults to 'epub', a theme designed to save
302
+ # visual space.
303
+ #epub_theme = 'epub'
304
+
305
+ # The language of the text. It defaults to the language option
306
+ # or 'en' if the language is not set.
307
+ #epub_language = ''
308
+
309
+ # The scheme of the identifier. Typical schemes are ISBN or URL.
310
+ #epub_scheme = ''
311
+
312
+ # The unique identifier of the text. This can be a ISBN number
313
+ # or the project homepage.
314
+ #epub_identifier = ''
315
+
316
+ # A unique identification for the text.
317
+ #epub_uid = ''
318
+
319
+ # A tuple containing the cover image and cover page html template filenames.
320
+ #epub_cover = ()
321
+
322
+ # A sequence of (type, uri, title) tuples for the guide element of content.opf.
323
+ #epub_guide = ()
324
+
325
+ # HTML files that should be inserted before the pages created by sphinx.
326
+ # The format is a list of tuples containing the path and title.
327
+ #epub_pre_files = []
328
+
329
+ # HTML files that should be inserted after the pages created by sphinx.
330
+ # The format is a list of tuples containing the path and title.
331
+ #epub_post_files = []
332
+
333
+ # A list of files that should not be packed into the epub file.
334
+ epub_exclude_files = ['search.html']
335
+
336
+ # The depth of the table of contents in toc.ncx.
337
+ #epub_tocdepth = 3
338
+
339
+ # Allow duplicate toc entries.
340
+ #epub_tocdup = True
341
+
342
+ # Choose between 'default' and 'includehidden'.
343
+ #epub_tocscope = 'default'
344
+
345
+ # Fix unsupported image types using the Pillow.
346
+ #epub_fix_images = False
347
+
348
+ # Scale large images.
349
+ #epub_max_image_width = 0
350
+
351
+ # How to display URL addresses: 'footnote', 'no', or 'inline'.
352
+ #epub_show_urls = 'inline'
353
+
354
+ # If false, no index is generated.
355
+ #epub_use_index = True