Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure compatibility with Python 3.11 #4

Closed
wants to merge 2 commits into from

Conversation

dtf0
Copy link
Contributor

@dtf0 dtf0 commented May 9, 2023

  • Replace deprecated getargspec() with getfullargspec()
  • Replace deprecated formatargspec() with custom implementation

Copied formatconfigargspec() from
sicherha/powerline@6238d9e after a number of
failed attempts to use inspect.signature or Signature directly as suggested.

Resolves errors in Python 3.11 & warnings in 3.10:

$ python3.11 zdeskcfg.py
Traceback (most recent call last):
  File "zdeskcfg/zdeskcfg.py", line 161, in <module>
    @configure()
     ^^^^^^^^^^^
  File "zdeskcfg/zdeskcfg.py", line 36, in __call__
    tgt_argspec = inspect.getargspec(tgt_func)
                  ^^^^^^^^^^^^^^^^^^
AttributeError: module 'inspect' has no attribute 'getargspec'. Did you mean: 'getargs'?

$ python3.10 zdeskcfg.py
zdeskcfg/zdeskcfg.py:36: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
  tgt_argspec = inspect.getargspec(tgt_func)
zdeskcfg/zdeskcfg.py:42: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
  argspec = inspect.getargspec(tgt_func)
zdeskcfg/zdeskcfg.py:53: DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
  signature = inspect.formatargspec(
zdeskcfg/zdeskcfg.py:66: DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
  newsignature = inspect.formatargspec(*newargspec)[1:-1]

dtf0 added 2 commits May 9, 2023 14:36
- Replace deprecated `getargspec()` with `getfullargspec()`
- Replace deprecated `formatargspec()` with custom implementation

Copied `formatconfigargspec()` from
sicherha/powerline@6238d9e after a number of
failed attempts to use `inspect.signature` or `Signature` directly as suggested.

Resolves errors in Python 3.11 & warnings in 3.10:
```
$ python3.11 zdeskcfg.py
Traceback (most recent call last):
  File "zdeskcfg/zdeskcfg.py", line 161, in <module>
    @configure()
     ^^^^^^^^^^^
  File "zdeskcfg/zdeskcfg.py", line 36, in __call__
    tgt_argspec = inspect.getargspec(tgt_func)
                  ^^^^^^^^^^^^^^^^^^
AttributeError: module 'inspect' has no attribute 'getargspec'. Did you mean: 'getargs'?

$ python3.10 zdeskcfg.py
zdeskcfg/zdeskcfg.py:36: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
  tgt_argspec = inspect.getargspec(tgt_func)
zdeskcfg/zdeskcfg.py:42: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
  argspec = inspect.getargspec(tgt_func)
zdeskcfg/zdeskcfg.py:53: DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
  signature = inspect.formatargspec(
zdeskcfg/zdeskcfg.py:66: DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
  newsignature = inspect.formatargspec(*newargspec)[1:-1]
```
@dtf0 dtf0 closed this May 9, 2023
@dtf0 dtf0 deleted the python3-compatibility branch May 9, 2023 22:11
@dtf0 dtf0 restored the python3-compatibility branch May 9, 2023 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant