Hi Harry,
Thanks for your email !

That’s exactly what I do when you turn the “enable_introspection” flag on, but 
frankly I am not at all satisfied with my implementation today: it does not 
work from iPython/jupyter, and does not seem to work on classes either because 
the inspect.stack() that I am relying on does not seem to have the same 
behavior for functions and classes, in particular classes that have nested 
methods.

You can have more details about this hack in the 
`disambiguate_using_introspection` method:
https://github.com/smarie/python-decopatch/blob/master/decopatch/utils_disambiguation.py#L210

Kind regards

Sylvain


De : Harry Percival <harry.perci...@gmail.com>
Envoyé : mardi 12 mars 2019 15:04
À : Sylvain MARIE <sylvain.ma...@se.com>
Cc : pytest-dev@python.org
Objet : Re: [pytest-dev] decorators and signature-preserving wrappers


[External email: Use caution with links and attachments]

________________________________


fascinating. re the last suggestion in your pep, inspect.is_in_decorator_stack, 
I don't have much experience of inspect, but couldn't you build a hacky version 
of that already by, I don't know, looking at the source of decorator arguments 
and parsing it for @s or something?
On Tue, 12 Mar 2019, 09:44 Sylvain MARIE via pytest-dev, 
<pytest-dev@python.org<mailto:pytest-dev@python.org>> wrote:

(wrong title in previous email, sorry)



Dear pytest enthusiasts,



This is not pytest per se but quite low-level python so you may find it 
interesting also for pytest, that has many decorators.



--

Writing python decorators is quite a tideous process, in particular when you 
wish to add arguments, and in particular in two cases : all optional arguments, 
and one mandatory argument. Indeed in these two cases there is a need to 
disambiguate between no-parenthesis and with-parenthesis usage.



After having struggled with this pattern for two years in various open source 
and industrial projects, I ended up writing a library to hopefully solve this 
once and for all: 
https://smarie.github.io/python-decopatch/<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsmarie.github.io%2Fpython-decopatch%2F&data=02%7C01%7Csylvain.marie%40se.com%7C42fa3fbab3244d3708b908d6a6f3a318%7C6e51e1adc54b4b39b5980ffe9ae68fef%7C0%7C0%7C636879962679467102&sdata=Jk%2FAsbD0oXtXQiKfVlHV6M7Pb0T%2BGSs74Rqrfoq2iWI%3D&reserved=0>
 . It is extensively tested (203 tests) against many combinations of 
signature/calls.

I would gladly appreciate any feedback !



Please note that there is a "PEP proposal draft" in the project page because I 
belive that the best a library can do will always be a poor workaround, where 
the interpreter or stdlib could really fix it properly.

Sorry for not providing too much implementation details in that page, my 
knowledge of the python interpreter is unfortunately quite limited.



--



Finally there is an additional topic around decorators : people tend to believe 
that decorators and function wrappers are the same, which is absolutely not the 
case. I used the famous `decorator` lib in many projects but I was not 
satisfied because it was solving both issues at the same time, maintaining the 
confusion. I therefore proposed 
https://smarie.github.io/python-makefun/<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsmarie.github.io%2Fpython-makefun%2F&data=02%7C01%7Csylvain.marie%40se.com%7C42fa3fbab3244d3708b908d6a6f3a318%7C6e51e1adc54b4b39b5980ffe9ae68fef%7C0%7C0%7C636879962679477111&sdata=crTX9XI%2B81ssAiNR3O4%2FFi2pO9%2FRvqUrNxzo42%2BBSPk%3D&reserved=0>
 . In particular it provides an equivalent of `@functools.wraps` that is truly 
signature-preserving (based on the same recipe than `decorator`).

Once again, any feedback would be gladly appreciated !



Kind regards



--

Sylvain

De : pytest-dev 
<pytest-dev-bounces+sylvain.marie=se....@python.org<mailto:pytest-dev-bounces+sylvain.marie=se....@python.org>>
 De la part de Guilherme Zagatti
Envoyé : vendredi 8 mars 2019 17:42
À : pytest-dev@python.org<mailto:pytest-dev@python.org>
Objet : [pytest-dev] pytest-airflow plugin


[External email: Use caution with links and attachments]

________________________________


Dear Pytest Development Community,

My name is Guilherme Zagatti. I am a developer at Flowminder, an award winning 
social-enterprise especializing in the use of Big Data for international 
development.

We are big fans of pytest. We needed to integrate pytest with Airflow to 
develop data quality assurance tests before ingesting data to our databases. 
Therefore we created the pytest-airflow pluging.

We just made it available to 
pypi<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpypi.org%2Fproject%2Fpytest-airflow%2F&data=02%7C01%7Csylvain.marie%40se.com%7C42fa3fbab3244d3708b908d6a6f3a318%7C6e51e1adc54b4b39b5980ffe9ae68fef%7C0%7C0%7C636879962679477111&sdata=jsmnhuHJWw00uMm0RymIZiYCBbgU5HNwyGmYQKWpiiA%3D&reserved=0>
 and open sourced in 
Github<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FFlowminder%2Fpytest-airflow&data=02%7C01%7Csylvain.marie%40se.com%7C42fa3fbab3244d3708b908d6a6f3a318%7C6e51e1adc54b4b39b5980ffe9ae68fef%7C0%7C0%7C636879962679487121&sdata=xakjHDVS%2Fo9k6UVatBGK8ThZ97jKRGvzUuSQBvb77Vc%3D&reserved=0>.
 It would be great to receive feedback from the pytest community and your 
suggestions on how to best promote the plugin to other users.

I am available to provide further details on the plugin. In the meanwhile, I 
have made available an architecture 
documentation<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FFlowminder%2Fpytest-airflow%2Fblob%2Fmaster%2Fdocs%2Farchitecture.md&data=02%7C01%7Csylvain.marie%40se.com%7C42fa3fbab3244d3708b908d6a6f3a318%7C6e51e1adc54b4b39b5980ffe9ae68fef%7C0%7C0%7C636879962679497130&sdata=8jdgQ4JoC13fxj41Au8cjJQ0kTZg9WwTbMtt1zQTPTA%3D&reserved=0>
 that contains a primer on pytest and detailed explanation of the plugin. 
Perhaps the contents of this document is of interest to the pytest community 
more generally. Feel free to provide comments and share more widely.

Again, very-well done for maintaining pytest.

Best,

Guilherme Zagatti

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________
_______________________________________________
pytest-dev mailing list
pytest-dev@python.org<mailto:pytest-dev@python.org>
https://mail.python.org/mailman/listinfo/pytest-dev<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpytest-dev&data=02%7C01%7Csylvain.marie%40se.com%7C42fa3fbab3244d3708b908d6a6f3a318%7C6e51e1adc54b4b39b5980ffe9ae68fef%7C0%7C0%7C636879962679497130&sdata=i5dLy81s6Ii6HEOU27DiTtS%2BMEaOnPWar7IZ1d7bbZg%3D&reserved=0>
--

--
Harry Percival
+44 78877 02511

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________
_______________________________________________
pytest-dev mailing list
pytest-dev@python.org
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to