Just fyi there is a pull request on pastedeploy that patches the inspect issue on 3.12. I’m planning to get that released when I can find time this week.
- Michael > On Nov 14, 2023, at 15:34, Laurent Daverio <ldave...@gmail.com> wrote: > > Glad to hear that, and many thanks for offering :) I'll let you know if I > need. > > You just mentioned a database, and it may be totally > irrelevant/unrelated, but it occurs to me that SQLAlchemy also has an > "inspect" function, which you use for introspecting your database. I > do use it, unlike the standard "inspect" :) > > All the best, > > Laurent. > >> Le mar. 14 nov. 2023 à 22:29, Oberdan Santos <sc.ober...@gmail.com> a écrit : >> >> >> Thanks for the support. The error is gone, now I can see communication with >> the database. >> My specialty is developing prediction models (Machine learning). If you need >> anything in this field, I am at your disposal. >>> Em terça-feira, 14 de novembro de 2023 às 17:17:54 UTC-3, Laurent Daverio >>> escreveu: >>> >>> Our messages crossed, my previous one contains the answer to your question: >>> >>> https://github.com/Pylons/pastedeploy/blame/main/src/paste/deploy/util.py#L36 >>> >>> Le mar. 14 nov. 2023 à 21:13, Oberdan Santos <sc.ob...@gmail.com> a écrit : >>>> >>>> Checking the literature on some sites, I see that I have two options ( >>>> inspect.signature() or inspect.getfullargspec() to solve the problem. The >>>> question is: How to use inspect.signature() or the other option, where to >>>> change it ? .The following is the function that was throwing error. >>>> >>>> import inspect >>>> import sys >>>> >>>> try: >>>> import importlib.metadata as importlib_metadata # noqa F401 >>>> except ImportError: # pragma: no cover >>>> # bw-compat shim for py37 >>>> import importlib_metadata # noqa F401 >>>> >>>> >>>> def fix_type_error(exc_info, callable, varargs, kwargs): >>>> """ >>>> Given an exception, this will test if the exception was due to a >>>> signature error, and annotate the error with better information if >>>> so. >>>> >>>> Usage:: >>>> >>>> try: >>>> val = callable(*args, **kw) >>>> except TypeError: >>>> exc_info = fix_type_error(None, callable, args, kw) >>>> raise exc_info[0], exc_info[1], exc_info[2] >>>> """ >>>> if exc_info is None: >>>> exc_info = sys.exc_info() >>>> if ( >>>> exc_info[0] != TypeError >>>> or str(exc_info[1]).find('arguments') == -1 >>>> or getattr(exc_info[1], '_type_error_fixed', False) >>>> ): >>>> return exc_info >>>> exc_info[1]._type_error_fixed = True >>>> argspec = inspect.formatargspec(*inspect.getargspec(callable)) >>>> args = ', '.join(map(_short_repr, varargs)) >>>> if kwargs and args: >>>> args += ', ' >>>> if kwargs: >>>> kwargs = sorted(kwargs.items()) >>>> args += ', '.join(['%s=...' % n for n, v in kwargs]) >>>> gotspec = '(%s)' % args >>>> msg = f'{exc_info[1]}; got {gotspec}, wanted {argspec}' >>>> exc_info[1].args = (msg,) >>>> return exc_info >>>> >>>> >>>> >>>> Desde já agradeço, >>>> ] >>>> Oberdan Costa >>>> >>>> Em terça-feira, 14 de novembro de 2023 às 16:15:50 UTC-3, Oberdan Santos >>>> escreveu: >>>>> >>>>> Thanks again for your attention. I will provide a brief contextualization. >>>>> I have a script based on FASTAPI for predicting the risk of chronic >>>>> non-communicable diseases to aid clinical decision making in primary >>>>> health care (backend), for now I will leave it like that. it works >>>>> perfectly. >>>>> On the frontend I use streamlit to obtain the results of up to 10 chronic >>>>> diseases simultaneously. This ended up growing to include other modules >>>>> (routing and intelligent management). At the moment I'm looking for a >>>>> robust framework for this application purpose and the pyramid environment >>>>> has allowed me to move in this direction (I'm based on cookiecutter) for >>>>> my first experiences. I have a modular division already structured. >>>>> Now I'm trying to connect to my database structure and I'm encountering >>>>> this error when I run my application. From the request: I need help to >>>>> take this step and fix this problem. >>>>> >>>>> Em terça-feira, 14 de novembro de 2023 às 16:00:06 UTC-3, Laurent Daverio >>>>> escreveu: >>>>>> >>>>>>> The application I am requesting support for is based on the Pyramd >>>>>>> Cookiecutter application framework. In this sense, my question is >>>>>>> pertinent. >>>>>> >>>>>> Oh, I see why you posted here, sorry then. For my defence, you >>>>>> provided no context, no traceback, nothing indicating you were indeed >>>>>> referring to Pyramid. You only wrote "When trying to run my code I am >>>>>> receiving an error", and your code was only standard Python. >>>>>> >>>>>>> Why does pyramid continue to carry this module in its base application >>>>>>> structures, such as cookiecutter? >>>>>> >>>>>> Actually, I'm not sure what problem you encountered : >>>>>> >>>>>> - it could be in the cookiecutter module, which is not related to >>>>>> Pyramid at all. It's definitely not a "base application structure" of >>>>>> Pyramid. I don't use "cookiecutter" very often, but I'm pretty sure I >>>>>> have used it with Python 3.11, and had no problem. >>>>>> >>>>>> - it could be in the Pyramid scaffold you used, which is indirectly >>>>>> related to Pyramid. I haven't used the "official" scaffold in a while, >>>>>> but I fail to see why it would create a base application which >>>>>> includes the "inspect" module. >>>>>> >>>>>> - it could be in Pyramid itself. But I would rule out that choice, as >>>>>> I use Pyramid with Python 3.11 daily, and the problem doesn't exist >>>>>> for me. >>>>>> >>>>>> When does your problem happen? When you're trying to use cookiecutter, >>>>>> or when you try to launch the generated app? >>>>>> >>>>>> Laurent. >>>>>> >>>>>> PS: just a clarification in what I wrote previously: standard module >>>>>> "inspect" is not deprecated at all, only function "formatargspec" is. >>>>>> >>>>>>> >>>>>>> Em terça-feira, 14 de novembro de 2023 às 15:30:53 UTC-3, Laurent >>>>>>> Daverio escreveu: >>>>>>>> >>>>>>>> Hello, >>>>>>>> >>>>>>>> a couple of remarks before replying to your question : >>>>>>>> >>>>>>>> 1/ This list is dedicated to Pylons and Pyramid, so a general question >>>>>>>> about the Python standard library is off-topic >>>>>>>> 2/ You could have googled "inspect formatargspec" and found answers >>>>>>>> 3/ You could have read the documentation of the standard library >>>>>>>> >>>>>>>> The documentation of "inspect" for Python 3.10 >>>>>>>> (https://docs.python.org/3.10/library/inspect.html) states : >>>>>>>> >>>>>>>> "Deprecated since version 3.5: Use signature() and Signature Object, >>>>>>>> which provide a better introspecting API for callables." >>>>>>>> >>>>>>>> And indeed, if you switch to the Python 3.11 / 3.12 versions of the >>>>>>>> docs, you'll find that the function has been removed. You certainly >>>>>>>> had a deprecation warning in Python 3.9/3.10, which you ignored >>>>>>>> >>>>>>>> My $0.02, >>>>>>>> >>>>>>>> Laurent. >>>>>>>> >>>>>>>> >>>>>>>> Le mar. 14 nov. 2023 à 19:17, Oberdan Santos <sc.ob...@gmail.com> a >>>>>>>> écrit : >>>>>>>>> >>>>>>>>> Hello!! >>>>>>>>> When trying to run my code I am receiving an error. >>>>>>>>> >>>>>>>>> import inspect >>>>>>>>> import sys >>>>>>>>> >>>>>>>>> try: >>>>>>>>> import importlib.metadata as importlib_metadata # noqa F401 >>>>>>>>> except ImportError: # pragma: no cover >>>>>>>>> # bw-compat shim for py37 >>>>>>>>> import importlib_metadata # noqa F401 >>>>>>>>> >>>>>>>>> >>>>>>>>> def fix_type_error(exc_info, callable, varargs, kwargs): >>>>>>>>> """ >>>>>>>>> Given an exception, this will test if the exception was due to a >>>>>>>>> signature error, and annotate the error with better information if >>>>>>>>> so. >>>>>>>>> >>>>>>>>> Usage:: >>>>>>>>> >>>>>>>>> try: >>>>>>>>> val = callable(*args, **kw) >>>>>>>>> except TypeError: >>>>>>>>> exc_info = fix_type_error(None, callable, args, kw) >>>>>>>>> raise exc_info[0], exc_info[1], exc_info[2] >>>>>>>>> """ >>>>>>>>> if exc_info is None: >>>>>>>>> exc_info = sys.exc_info() >>>>>>>>> if ( >>>>>>>>> exc_info[0] != TypeError >>>>>>>>> or str(exc_info[1]).find('arguments') == -1 >>>>>>>>> or getattr(exc_info[1], '_type_error_fixed', False) >>>>>>>>> ): >>>>>>>>> return exc_info >>>>>>>>> exc_info[1]._type_error_fixed = True >>>>>>>>> argspec = inspect.formatargspec(*inspect.getargspec(callable)) >>>>>>>>> args = ', '.join(map(_short_repr, varargs)) >>>>>>>>> if kwargs and args: >>>>>>>>> args += ', ' >>>>>>>>> if kwargs: >>>>>>>>> kwargs = sorted(kwargs.items()) >>>>>>>>> args += ', '.join(['%s=...' % n for n, v in kwargs]) >>>>>>>>> gotspec = '(%s)' % args >>>>>>>>> msg = f'{exc_info[1]}; got {gotspec}, wanted {argspec}' >>>>>>>>> exc_info[1].args = (msg,) >>>>>>>>> return exc_info >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> ERRO: >>>>>>>>> AttributeError: module 'inspect' has no attribute 'formatargspec'. >>>>>>>>> Did you mean: 'formatargvalues'? >>>>>>>>> >>>>>>>>> >>>>>>>>> I've tried some changes to the code line, but to no avail. >>>>>>>>> argspec = inspect.formatargspec(*inspect.getargspec(callable)) >>>>>>>>> Every help is welcome >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> You received this message because you are subscribed to the Google >>>>>>>>> Groups "pylons-discuss" group. >>>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>>> send an email to pylons-discus...@googlegroups.com. >>>>>>>>> To view this discussion on the web visit >>>>>>>>> https://groups.google.com/d/msgid/pylons-discuss/cab4b239-75df-44ba-9d39-4fea371e2b6dn%40googlegroups.com. >>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "pylons-discuss" group. >>>>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>>>> an email to pylons-discus...@googlegroups.com. >>>>>>> To view this discussion on the web visit >>>>>>> https://groups.google.com/d/msgid/pylons-discuss/82cb0cf3-0b00-4e6c-b788-3c71905f196an%40googlegroups.com. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google Groups >>>> "pylons-discuss" group. >>>> To unsubscribe from this group and stop receiving emails from it, send an >>>> email to pylons-discus...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/pylons-discuss/f175279d-69fc-46fb-81dd-55b88aa93974n%40googlegroups.com. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "pylons-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to pylons-discuss+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/pylons-discuss/c9a5d252-4bc8-471f-98d9-15fa440702bdn%40googlegroups.com. > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pylons-discuss+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pylons-discuss/CAB7cU6w_gUL3gVzP1gKepEPOkD-RaciEMdptrbmKoft6xGSG0w%40mail.gmail.com. -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/7A6B57F4-0DD8-493C-B66C-D0EC9AC34224%40gmail.com.