erikrose / parsimonious

The fastest pure-Python PEG parser I can muster
MIT License
1.79k stars 126 forks source link

Python 3.11 : cannot import name 'getargspec' from 'inspect' #225

Closed OrJaku closed 1 year ago

OrJaku commented 1 year ago

I found error on my environment after upgrade python 3.10.5 to 3.11.0 Python 3.11.0b5 FastAPI: 0.85.1 OS: Ubuntu 22.04

  File "/build/src/node_api.py", line 2, in <module>
    from web3 import Web3
  File "/usr/local/lib/python3.11/site-packages/web3/__init__.py", line 6, in <module>
    from eth_account import (
  File "/usr/local/lib/python3.11/site-packages/eth_account/__init__.py", line 1, in <module>
    from eth_account.account import (
  File "/usr/local/lib/python3.11/site-packages/eth_account/account.py", line 59, in <module>
    from eth_account.messages import (
  File "/usr/local/lib/python3.11/site-packages/eth_account/messages.py", line 26, in <module>
    from eth_account._utils.structured_data.hashing import (
  File "/usr/local/lib/python3.11/site-packages/eth_account/_utils/structured_data/hashing.py", line 9, in <module>
    from eth_abi import (
  File "/usr/local/lib/python3.11/site-packages/eth_abi/__init__.py", line 6, in <module>
    from eth_abi.abi import (  # NOQA
  File "/usr/local/lib/python3.11/site-packages/eth_abi/abi.py", line 1, in <module>
    from eth_abi.codec import (
  File "/usr/local/lib/python3.11/site-packages/eth_abi/codec.py", line 16, in <module>
    from eth_abi.decoding import (
  File "/usr/local/lib/python3.11/site-packages/eth_abi/decoding.py", line 14, in <module>
    from eth_abi.base import (
  File "/usr/local/lib/python3.11/site-packages/eth_abi/base.py", line 7, in <module>
    from .grammar import (
  File "/usr/local/lib/python3.11/site-packages/eth_abi/grammar.py", line 4, in <module>
    import parsimonious
  File "/usr/local/lib/python3.11/site-packages/parsimonious/__init__.py", line 9, in <module>
    from parsimonious.grammar import Grammar, TokenGrammar
  File "/usr/local/lib/python3.11/site-packages/parsimonious/grammar.py", line 14, in <module>
    from parsimonious.expressions import (Literal, Regex, Sequence, OneOf,
  File "/usr/local/lib/python3.11/site-packages/parsimonious/expressions.py", line 9, in <module>
    from inspect import getargspec
ImportError: cannot import name 'getargspec' from 'inspect' (/usr/local/lib/python3.11/inspect.py)
lucaswiman commented 1 year ago

The usage is here: https://github.com/erikrose/parsimonious/blob/d5636a6ae4d7fe2ddb96f567e289ab3eeb454b49/parsimonious/expressions.py#L67-L82

Since we've dropped support for old versions of python, I think we can use inspect.signature instead. Happy to review/push a PR implementing that.

FastAPI: 0.85.1

Arguably the version of parsimonious might be more relevant 😄. It looks like you're using an older version since the current code uses getfullargspec instead of getargspec. I would recommend upgrading, since we won't backport a fix to the older version.

OrJaku commented 1 year ago

I can't update parsimonious because if I do it I have problem with installation of newest package eth-abi (eth-abi 2.2.0 depends on parsimonious<0.9.0 and >=0.8.0) :/

lucaswiman commented 1 year ago

It seems the function currently in use (getfullargspec) is not even deprecated in 3.11, so I don't think there's anything to do.