Giter Club home page Giter Club logo

Comments (5)

mottosso avatar mottosso commented on July 20, 2024

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.

Muream avatar Muream commented on July 20, 2024

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.

mottosso avatar mottosso commented on July 20, 2024

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.

Muream avatar Muream commented on July 20, 2024

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.

mottosso avatar mottosso commented on July 20, 2024

Awesome!

from cmdx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.