Skip to content

Commit

Permalink
Merge pull request #41 from benblo/Ben/pylance-typing
Browse files Browse the repository at this point in the history
add some Pylance-friendly typing information
  • Loading branch information
mottosso authored Nov 30, 2020
2 parents 03236ff + 6759739 commit f44c0d8
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions cmdx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# -*- coding: utf-8 -*-

# Hack for static typing analysis:
# the test below only passes in the IDE (eg VsCode); Maya doesn't know or care about typing.
MYPY = False
if MYPY:
from typing import *
# fake-declare some Python2-only types to fix Pylance analyzer false positives (Pylance is Python3-only)
basestring = unicode = str
long = int
buffer = bytearray
file = object
del MYPY

import os
import sys
import json
Expand Down Expand Up @@ -3119,7 +3131,7 @@ def rotatePivot(self, space=None):
space = space or sTransform
return super(TransformationMatrix, self).rotatePivot(space)

def translation(self, space=None):
def translation(self, space=None): # type: (om.MSpace) -> om.MVector
"""This method does not typically support optional arguments"""
space = space or sTransform
return super(TransformationMatrix, self).translation(space)
Expand Down Expand Up @@ -3173,10 +3185,10 @@ def setRotation(self, rot):

return super(TransformationMatrix, self).setRotation(rot)

def asMatrix(self):
def asMatrix(self): # type: () -> om.MMatrix
return MatrixType(super(TransformationMatrix, self).asMatrix())

def asMatrixInverse(self):
def asMatrixInverse(self): # type: () -> om.MMatrix
return MatrixType(super(TransformationMatrix, self).asMatrixInverse())

# A more intuitive alternative
Expand Down Expand Up @@ -3866,7 +3878,7 @@ def _python_to_mod(value, plug, mod):
return True


def encode(path):
def encode(path): # type: (str) -> Node
"""Convert relative or absolute `path` to cmdx Node
Fastest conversion from absolute path to Node
Expand Down

0 comments on commit f44c0d8

Please sign in to comment.