Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-makefun for openSUSE:Factory 
checked in at 2022-12-03 10:03:45
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-makefun (Old)
 and      /work/SRC/openSUSE:Factory/.python-makefun.new.1835 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-makefun"

Sat Dec  3 10:03:45 2022 rev:4 rq:1039664 version:1.15.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-makefun/python-makefun.changes    
2022-09-30 17:58:06.945289822 +0200
+++ /work/SRC/openSUSE:Factory/.python-makefun.new.1835/python-makefun.changes  
2022-12-03 10:04:01.439369479 +0100
@@ -1,0 +2,7 @@
+Fri Dec  2 20:29:56 UTC 2022 - Yogalakshmi Arunachalam <[email protected]>
+
+- Update to version 1.15.0
+  Moved auto signature string to Signature object conversion to wraps. …
+      …Added a test.
+
+-------------------------------------------------------------------

Old:
----
  makefun-1.14.0.tar.gz

New:
----
  makefun-1.15.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-makefun.spec ++++++
--- /var/tmp/diff_new_pack.4KskhB/_old  2022-12-03 10:04:02.431374992 +0100
+++ /var/tmp/diff_new_pack.4KskhB/_new  2022-12-03 10:04:02.435375014 +0100
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-makefun
-Version:        1.14.0
+Version:        1.15.0
 Release:        0
 License:        BSD-3-Clause
 Summary:        Small library to dynamically create python functions

++++++ makefun-1.14.0.tar.gz -> makefun-1.15.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/makefun-1.14.0/PKG-INFO new/makefun-1.15.0/PKG-INFO
--- old/makefun-1.14.0/PKG-INFO 2022-06-21 23:27:52.000000000 +0200
+++ new/makefun-1.15.0/PKG-INFO 2022-09-08 11:19:50.000000000 +0200
@@ -1,14 +1,13 @@
 Metadata-Version: 2.1
 Name: makefun
-Version: 1.14.0
+Version: 1.15.0
 Summary: Small library to dynamically create python functions.
 Home-page: https://github.com/smarie/python-makefun
-Download-URL: https://github.com/smarie/python-makefun/tarball/1.14.0
+Download-URL: https://github.com/smarie/python-makefun/tarball/1.15.0
 Author: Sylvain MARIE <[email protected]>
 Maintainer: Sylvain MARIE <[email protected]>
 License: BSD 3-Clause
 Keywords: decorate decorator compile make dynamic function generate generation 
define definition signature args wrapper wraps
-Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: Intended Audience :: Developers
 Classifier: License :: OSI Approved :: BSD License
@@ -36,5 +35,3 @@
 The documentation for users is available here: 
[https://smarie.github.io/python-makefun/](https://smarie.github.io/python-makefun/)
 
 A readme for developers is available here: 
[https://github.com/smarie/python-makefun](https://github.com/smarie/python-makefun)
-
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/makefun-1.14.0/docs/api_reference.md 
new/makefun-1.15.0/docs/api_reference.md
--- old/makefun-1.14.0/docs/api_reference.md    2022-06-21 23:26:54.000000000 
+0200
+++ new/makefun-1.15.0/docs/api_reference.md    2022-09-08 11:18:50.000000000 
+0200
@@ -166,7 +166,7 @@
 
 In other words, as opposed to `@with_signature`, the metadata (doc, module 
name, etc.) is provided by the wrapped `wrapped_fun`, so that the created 
function seems to be identical (except possiblyfor the signature). Note that 
all options in `with_signature` can still be overrided using parameters of 
`@wraps`.
 
-If the signature is *not* modified through `new_sig`, `remove_args`, 
`append_args` or `prepend_args`, the additional `__wrapped__` attribute  on the 
created function, to stay consistent with the `functools.wraps` behaviour.
+The additional `__wrapped__` attribute is added on the created function, to 
stay consistent with the `functools.wraps` behaviour. If the signature is 
modified through `new_sig`, `remove_args`, `append_args` or `prepend_args`, the 
`__signature__` attribute will be added per [PEP 
362](https://peps.python.org/pep-0362/).
 
 See also [python documentation on 
@wraps](https://docs.python.org/3/library/functools.html#functools.wraps)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/makefun-1.14.0/docs/changelog.md 
new/makefun-1.15.0/docs/changelog.md
--- old/makefun-1.14.0/docs/changelog.md        2022-06-21 23:26:54.000000000 
+0200
+++ new/makefun-1.15.0/docs/changelog.md        2022-09-08 11:18:50.000000000 
+0200
@@ -1,5 +1,9 @@
 # Changelog
 
+### 1.15.0 - More PEP-compliant `wraps`
+
+ - `wraps` now always sets the `__wrapped__` attribute, and also sets the 
`__signature__` attribute when the signature changes, as specified by PEP 362. 
PR []() by [#86](https://github.com/smarie/python-makefun/pull/86) by 
[lucaswiman](https://github.com/lucaswiman).
+
 ### 1.14.0 - Support for lambda functions
 
  - `create_wrapper`, `create_function`, `wraps` and `with_signature` now 
support lambda functions. They also accept a new parameter `co_name` to define 
the name to be used in the compiled code. PR 
[#80](https://github.com/smarie/python-makefun/pull/80) by 
[andrewcleveland](https://github.com/andrewcleveland).
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/makefun-1.14.0/noxfile.py 
new/makefun-1.15.0/noxfile.py
--- old/makefun-1.14.0/noxfile.py       2022-06-21 23:26:54.000000000 +0200
+++ new/makefun-1.15.0/noxfile.py       2022-09-08 11:18:50.000000000 +0200
@@ -146,7 +146,6 @@
     """Launch flake8 qualimetry."""
 
     session.install("-r", str(Folders.ci_tools / "flake8-requirements.txt"))
-    session.install("genbadge[flake8]")
     session.run2("pip install .")
 
     rm_folder(Folders.flake8_reports)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/makefun-1.14.0/pyproject.toml 
new/makefun-1.15.0/pyproject.toml
--- old/makefun-1.14.0/pyproject.toml   2022-06-21 23:26:54.000000000 +0200
+++ new/makefun-1.15.0/pyproject.toml   2022-09-08 11:18:50.000000000 +0200
@@ -2,7 +2,6 @@
 requires = [
     "setuptools>=39.2",
     "setuptools_scm",
-    "wheel"
 ]
 build-backend = "setuptools.build_meta"
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/makefun-1.14.0/src/makefun/_version.py 
new/makefun-1.15.0/src/makefun/_version.py
--- old/makefun-1.14.0/src/makefun/_version.py  2022-06-21 23:27:51.000000000 
+0200
+++ new/makefun-1.15.0/src/makefun/_version.py  2022-09-08 11:19:50.000000000 
+0200
@@ -1,5 +1,5 @@
 # coding: utf-8
 # file generated by setuptools_scm
 # don't change, don't track in version control
-__version__ = version = '1.14.0'
-__version_tuple__ = version_tuple = (1, 14, 0)
+__version__ = version = '1.15.0'
+__version_tuple__ = version_tuple = (1, 15, 0)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/makefun-1.14.0/src/makefun/main.py 
new/makefun-1.15.0/src/makefun/main.py
--- old/makefun-1.14.0/src/makefun/main.py      2022-06-21 23:26:54.000000000 
+0200
+++ new/makefun-1.15.0/src/makefun/main.py      2022-09-08 11:18:50.000000000 
+0200
@@ -819,9 +819,11 @@
     `wrapped_fun`, so that the created function seems to be identical (except 
possiblyfor the signature).
     Note that all options in `with_signature` can still be overrided using 
parameters of `@wraps`.
 
-    If the signature is *not* modified through `new_sig`, `remove_args`, 
`append_args` or `prepend_args`, the
-    additional `__wrapped__` attribute  on the created function, to stay 
consistent with the `functools.wraps`
-    behaviour.
+    The additional `__wrapped__` attribute is set on the created function, to 
stay consistent
+    with the `functools.wraps` behaviour. If the signature is modified through 
`new_sig`,
+    `remove_args`, `append_args` or `prepend_args`, the additional
+    `__signature__` attribute will be set so that `inspect.signature` and 
related functionality
+    works as expected. See PEP 362 for more detail on `__wrapped__` and 
`__signature__`.
 
     See also [python documentation on 
@wraps](https://docs.python.org/3/library/functools.html#functools.wraps)
 
@@ -960,15 +962,20 @@
 
     # attributes: start from the wrapped dict, add '__wrapped__' if needed, 
and override with all attrs.
     all_attrs = copy(getattr_partial_aware(wrapped, '__dict__'))
+    # PEP362: always set `__wrapped__`, and if signature was changed, set 
`__signature__` too
+    all_attrs["__wrapped__"] = wrapped
     if has_new_sig:
-        # change of signature: delete the __wrapped__ attribute if any
-        try:
-            del all_attrs['__wrapped__']
-        except KeyError:
-            pass
-    else:
-        # no change of signature: we can safely set the __wrapped__ attribute
-        all_attrs['__wrapped__'] = wrapped
+        if isinstance(func_sig, Signature):
+            all_attrs["__signature__"] = func_sig
+        else:
+            # __signature__ must be a Signature object, so if it is a string 
we need to evaluate it.
+            frame = _get_callerframe(offset=1)
+            evaldict, _ = extract_module_and_evaldict(frame)
+            # Here we could wish to directly override `func_name` and 
`func_sig` so that this does not have to be done
+            # again by `create_function` later... Would this be risky ?
+            _func_name, func_sig_as_sig, _ = 
get_signature_from_string(func_sig, evaldict)
+            all_attrs["__signature__"] = func_sig_as_sig
+
     all_attrs.update(attrs)
 
     return func_name, func_sig, doc, qualname, co_name, module_name, all_attrs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/makefun-1.14.0/src/makefun.egg-info/PKG-INFO 
new/makefun-1.15.0/src/makefun.egg-info/PKG-INFO
--- old/makefun-1.14.0/src/makefun.egg-info/PKG-INFO    2022-06-21 
23:27:52.000000000 +0200
+++ new/makefun-1.15.0/src/makefun.egg-info/PKG-INFO    2022-09-08 
11:19:50.000000000 +0200
@@ -1,14 +1,13 @@
 Metadata-Version: 2.1
 Name: makefun
-Version: 1.14.0
+Version: 1.15.0
 Summary: Small library to dynamically create python functions.
 Home-page: https://github.com/smarie/python-makefun
-Download-URL: https://github.com/smarie/python-makefun/tarball/1.14.0
+Download-URL: https://github.com/smarie/python-makefun/tarball/1.15.0
 Author: Sylvain MARIE <[email protected]>
 Maintainer: Sylvain MARIE <[email protected]>
 License: BSD 3-Clause
 Keywords: decorate decorator compile make dynamic function generate generation 
define definition signature args wrapper wraps
-Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: Intended Audience :: Developers
 Classifier: License :: OSI Approved :: BSD License
@@ -36,5 +35,3 @@
 The documentation for users is available here: 
[https://smarie.github.io/python-makefun/](https://smarie.github.io/python-makefun/)
 
 A readme for developers is available here: 
[https://github.com/smarie/python-makefun](https://github.com/smarie/python-makefun)
-
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/makefun-1.14.0/src/makefun.egg-info/SOURCES.txt 
new/makefun-1.15.0/src/makefun.egg-info/SOURCES.txt
--- old/makefun-1.14.0/src/makefun.egg-info/SOURCES.txt 2022-06-21 
23:27:52.000000000 +0200
+++ new/makefun-1.15.0/src/makefun.egg-info/SOURCES.txt 2022-09-08 
11:19:50.000000000 +0200
@@ -31,6 +31,7 @@
 src/makefun.egg-info/requires.txt
 src/makefun.egg-info/top_level.txt
 tests/__init__.py
+tests/_issue_85_module.py
 tests/_test_py35.py
 tests/_test_py36.py
 tests/_test_py38.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/makefun-1.14.0/tests/_issue_85_module.py 
new/makefun-1.15.0/tests/_issue_85_module.py
--- old/makefun-1.14.0/tests/_issue_85_module.py        1970-01-01 
01:00:00.000000000 +0100
+++ new/makefun-1.15.0/tests/_issue_85_module.py        2022-09-08 
11:18:50.000000000 +0200
@@ -0,0 +1,7 @@
+def forwardref_method(foo: "ForwardRef", bar: str) -> "ForwardRef":
+    return ForwardRef(foo.x + bar)
+
+
+class ForwardRef:
+    def __init__(self, x="default"):
+        self.x = x
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/makefun-1.14.0/tests/test_advanced.py 
new/makefun-1.15.0/tests/test_advanced.py
--- old/makefun-1.14.0/tests/test_advanced.py   2022-06-21 23:26:54.000000000 
+0200
+++ new/makefun-1.15.0/tests/test_advanced.py   2022-09-08 11:18:50.000000000 
+0200
@@ -245,3 +245,18 @@
         return a
 
     assert foo(10) == 10
+
+
[email protected](sys.version_info < (3, 5), reason="requires python 3.5 or 
higher (non-comment type hints)")
+def test_type_hint_error_sigchange():
+    """ Test for https://github.com/smarie/python-makefun/issues/32 """
+
+    from tests._test_py35 import make_ref_function
+    from typing import Any
+    ref_f = make_ref_function()
+
+    @wraps(ref_f, new_sig="(a: Any)")
+    def foo(a):
+        return a
+
+    assert foo(10) == 10
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/makefun-1.14.0/tests/test_issues.py 
new/makefun-1.15.0/tests/test_issues.py
--- old/makefun-1.14.0/tests/test_issues.py     2022-06-21 23:26:54.000000000 
+0200
+++ new/makefun-1.15.0/tests/test_issues.py     2022-09-08 11:18:50.000000000 
+0200
@@ -181,11 +181,10 @@
     def second_wrapper(foo, bar):
         return wrapper(foo) + bar
 
+    assert second_wrapper.__wrapped__ is wrapper
+    assert "bar" in signature(second_wrapper).parameters
     assert second_wrapper(1, -1) == 0
 
-    with pytest.raises(AttributeError):
-        second_wrapper.__wrapped__
-
 
 def test_issue_pr_67():
     """Test handcrafted for https://github.com/smarie/python-makefun/pull/67""";
@@ -253,3 +252,25 @@
     assert inspect.isasyncgenfunction(f_partial)
 
     assert 
asyncio.get_event_loop().run_until_complete(asyncio.ensure_future(f_partial().__anext__()))
 == 1
+
+
+
[email protected](sys.version_info < (3, 7, 6), reason="The __wrapped__ 
behavior in get_type_hints being tested was not added until python 3.7.6.")
+def test_issue_85_wrapped_forwardref_annotation():
+    import typing
+    from . import _issue_85_module
+
+    @wraps(_issue_85_module.forwardref_method, remove_args=["bar"])
+    def wrapper(**kwargs):
+        kwargs["bar"] = "x"  # python 2 syntax to prevent syntax error.
+        return _issue_85_module.forwardref_method(**kwargs)
+
+    # Make sure the wrapper function works as expected
+    assert wrapper(_issue_85_module.ForwardRef()).x == "defaultx"
+
+    # Check that the type hints of the wrapper are ok with the forward 
reference correctly resolved
+    expected_annotations = {
+        "foo": _issue_85_module.ForwardRef,
+        "return": _issue_85_module.ForwardRef,
+    }
+    assert typing.get_type_hints(wrapper) == expected_annotations

Reply via email to