Comments (5)
Heya @Muream,
The python 3 syntax is more comfortable to use though considering cmdx supports older versions of Maya, the comment based syntax is probably the only viable option
Indeed, at least until Maya 2020 is deprecated, so for at least another 3 years.
Would you be open for me to add that in?
Yes, on 1 condition.
- Line length
Sounds petty, but that has been my issue with these things in the past. I don't benefit from type hints personally, but if there's one thing I do benefit from it's multiple side-by-side editor views. From what I gather, the parsing mechanic behind defining these as comments is that the need to be on one line? What ends up happening then is that these lines grow beyond 80 chars wide, to 200+ depending on how many arguments there are. Even that small Python 2 example is dangerously close at 76 chars.
from cmdx.
Haha yes, I always have at least two editors side by side so I hear you
It's perfectly possible to have type annotations per line in a multiline function definition like so
def createNode(
type, # type: Union[str, MTypeId]
name=None, # type: Optional[str]
parent=None, # type: Optional[DagNode]
):
# type: (...) -> Node
...
Another option is to use a stub file. It's generally recommended to keep the annotations within the source file as that's just one file to maintain instead of two
But in this case, I think it might be the way to go since typing
needs to be imported for more advanced type annotations (like generics) and that won't be available for python 2 either without having it as a dependency which I'm pretty sure you'd rather not have
from cmdx.
I like the idea of a stub file, in that it would have little (to none?) effect on those that don't use typing. But it does sound rather tedious on your part, having to write (or generate?) this file.
I'd be up for seeing the start of a PR with these comment-based type-hints, to see what kind of effect/damage it would have on readability. Maybe it's not that bad? If it is, then there's always the stub file.
from cmdx.
Cool, generating a stub is easy with mypy and after that it's as much work cleaning it up as adding annotations to the source file itself and is actually likely to give me more freedom to implement things like Generics
I'll make a proof of concept PR in the next few days with a few different styles of annotations 👍
from cmdx.
Awesome!
from cmdx.
Related Issues (20)
- cmdx.listRelatives always returns None HOT 18
- Plugs not taking and returning UI units HOT 4
- DagNode.addChild crashes in certain circumstances HOT 6
- Modifiers and data types HOT 2
- design proposition for components HOT 10
- attributes' default value not saved in scene HOT 3
- Support for proxy attributes
- DGModifier.disconnect and Undo
- Attribute reuse and undo
- Multiple versions simultaneously
- How to debug Maya crashes? HOT 9
- Deploy on CI HOT 1
- Direct passing of cmdx.Node to vanilla cmds HOT 3
- Support keyframing of pairBlended attributes
- MObjectHandle hashCode... HOT 3
- Two users, one machine
- Thoughts on code formatter such as Black? HOT 5
- Set a nodes transform HOT 7
- Auto offset group
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cmdx.