Skip to content

Issue with Python 3.11, or type annotations: the inspect module changed #833

Description

@HacKanCuBa

I'm having an issue running invoke (latest) in Python 3.11-dev (3.11.0a3). For this tasks file, this is the trace I get:

root@18bb2bd21aaa:/b2s# poetry run inv tests
Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/blake2signer-uv6dtlQx-py3.11/bin/inv", line 8, in <module>
    sys.exit(program.run())
             ^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/blake2signer-uv6dtlQx-py3.11/lib/python3.11/site-packages/invoke/program.py", line 373, in run
    self.parse_collection()
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/blake2signer-uv6dtlQx-py3.11/lib/python3.11/site-packages/invoke/program.py", line 465, in parse_collection
    self.load_collection()
    ^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/blake2signer-uv6dtlQx-py3.11/lib/python3.11/site-packages/invoke/program.py", line 696, in load_collection
    module, parent = loader.load(coll_name)
                     ^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/blake2signer-uv6dtlQx-py3.11/lib/python3.11/site-packages/invoke/loader.py", line 76, in load
    module = imp.load_module(name, fd, path, desc)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/imp.py", line 235, in load_module
    return load_source(name, filename, file)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/imp.py", line 172, in load_source
    module = _load(spec)
             ^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 721, in _load
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 902, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/b2s/tasks.py", line 11, in <module>
    def flake8(ctx):
    ^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/blake2signer-uv6dtlQx-py3.11/lib/python3.11/site-packages/invoke/tasks.py", line 325, in task
    return klass(args[0], **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/blake2signer-uv6dtlQx-py3.11/lib/python3.11/site-packages/invoke/tasks.py", line 76, in __init__
    self.positional = self.fill_implicit_positionals(positional)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/blake2signer-uv6dtlQx-py3.11/lib/python3.11/site-packages/invoke/tasks.py", line 167, in fill_implicit_positionals
    args, spec_dict = self.argspec(self.body)
                      ^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/blake2signer-uv6dtlQx-py3.11/lib/python3.11/site-packages/invoke/tasks.py", line 153, in argspec
    spec = inspect.getargspec(func)
           ^^^^^^^^^^^^^^^^^^
AttributeError: module 'inspect' has no attribute 'getargspec'. Did you mean: 'getargs'?

It works perfectly fine for any other Python version I tried (3.7, 3.8, 3.9, 3.10, PyPy3.7, PyPy3.8, Stackless3.7, Stackless3.8).

The module inspect does indeed not have said attribute, and I see that there's a potential replacement done in invoke.vendor.decorator for some reason.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions