gyp-next icon indicating copy to clipboard operation
gyp-next copied to clipboard

Add type hints to Python function signatures

Open ryzokuken opened this issue 5 years ago • 11 comments

Add type information to the codebase. Thoughts? @cclauss @targos.

Ref: https://docs.python.org/3/library/typing.html

ryzokuken avatar Jul 15 '20 13:07 ryzokuken

I'm not used to Python and have never worked with typing, so my opinion wouldn't be very informed. I work with TypeScript though and do like type annotations, so I'm not opposed to that if it makes it easier / safer to develop and if it can be introduced incrementally.

targos avatar Jul 15 '20 15:07 targos

it makes it easier / safer to develop

it can be introduced incrementally

IIUC, these are both true for this.

ryzokuken avatar Jul 16 '20 10:07 ryzokuken

I am a huge fan of type hints in Python but they break compatibility with Python 2. If we a green light to drop legacy Python then let's go for it.

cclauss avatar Jul 16 '20 13:07 cclauss

Personally, I don't see why we should let Python 2 hold us back in 2020?

ryzokuken avatar Jul 17 '20 07:07 ryzokuken

As long as Node.js and node-gyp support Python 2 in their main development branches, I am against removing support here.

targos avatar Jul 17 '20 08:07 targos

Unfortunately, this is not a choice that one person can make. How do we get the Node.js Technical Steering Commitee to agree to drop support for legacy Python which died 200 days ago.

cclauss avatar Jul 17 '20 08:07 cclauss

You don't necessarily need the whole TSC to agree on it. The process is to open a PR dropping Python 2. If we cannot reach consensus (i.e. some collaborator(s) disagree), then the TSC will have to make a decision.

targos avatar Jul 17 '20 08:07 targos

@targos what does the PR need to do? Since the tooling is already Python 3 compatible, I suppose we're looking at a doc-only PR here.

ryzokuken avatar Jul 17 '20 11:07 ryzokuken

Almost doc-only, yes. There's also at least one place where we validate the python version (the configure file)

targos avatar Jul 17 '20 11:07 targos

Add Python type hints and drop support for Python 2 sounds like a nice PR title to me.

cclauss avatar Jul 17 '20 11:07 cclauss

drop support for Python 2 in nodejs/node first!

ryzokuken avatar Jul 17 '20 13:07 ryzokuken