Skip to content

Commit

Permalink
Merge pull request #380 from jedfrechette/master
Browse files Browse the repository at this point in the history
Improve compatibility with Python 3.10 and newer
  • Loading branch information
mottosso authored Jun 10, 2024
2 parents 444769c + e7b4242 commit ff91fc3
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 34 deletions.
8 changes: 7 additions & 1 deletion pyblish_qml/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

from . import ipc, settings, _state
from .vendor.six.moves import queue
from .vendor import six

if six.PY2:
get_arg_spec = inspect.getargspec
else:
get_arg_spec = inspect.getfullargspec

MODULE_DIR = os.path.dirname(__file__)
SPLASH_PATH = os.path.join(MODULE_DIR, "splash.png")
Expand All @@ -24,7 +30,7 @@ def register_dispatch_wrapper(wrapper):
"""

signature = inspect.getargspec(wrapper)
signature = get_arg_spec(wrapper)
if any([len(signature.args) != 1,
signature.varargs is None,
signature.keywords is None]):
Expand Down
12 changes: 9 additions & 3 deletions pyblish_qml/ipc/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
import traceback

from . import schema
from ..vendor import six

import pyblish.lib
import pyblish.plugin

log = logging.getLogger("pyblish")

if six.PY2:
get_arg_spec = inspect.getargspec
else:
get_arg_spec = inspect.getfullargspec


def extract_traceback(exception):
try:
Expand Down Expand Up @@ -253,7 +259,7 @@ def format_plugin(plugin):

has_repair = False

args = inspect.getargspec(plugin.repair).args
args = get_arg_spec(plugin.repair).args
if "context" in args or "instance" in args:
has_repair = True

Expand Down Expand Up @@ -293,10 +299,10 @@ def format_plugin(plugin):
"module": module,
"hasRepair": has_repair,
"process": {
"args": inspect.getargspec(plugin.process).args,
"args": get_arg_spec(plugin.process).args,
},
"repair": {
"args": inspect.getargspec(plugin.repair).args,
"args": get_arg_spec(plugin.repair).args,
},

"actions": [format_action(a) for a in plugin.actions],
Expand Down
8 changes: 7 additions & 1 deletion pyblish_qml/vendor/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
# may not have inspect
inspect = None

from . import six
if six.PY2:
get_arg_spec = inspect.getargspec
else:
get_arg_spec = inspect.getfullargspec

try:
from functools import wraps as original_wraps
except ImportError:
Expand Down Expand Up @@ -174,7 +180,7 @@ def _getsignature(func, skipfirst, instance=False):
regargs, varargs, varkw, defaults, kwonly, kwonlydef, ann = argspec
else:
try:
regargs, varargs, varkwargs, defaults = inspect.getargspec(func)
regargs, varargs, varkwargs, defaults = get_arg_spec(func)
except TypeError:
# C function / method, possibly inherited object().__init__
return
Expand Down
Loading

0 comments on commit ff91fc3

Please sign in to comment.