Closed jonathan-d-zhang closed 2 years ago
I'd go with "type hint" and "type hinting" rather than "typehint" and "typehinting" for consistency with the Python docs, but otherwise I love the idea!
I'd like to point out that it doesn't have to be a function,
a: int = 5
is perfectly valid. Perhaps something more like "A type hint indicates the type of a variable. It can also be used to show what type a function returns"
Note that this has no actual effect on what is passed, for example, this is valid code
add("hey", ["yo", 2])
This is not valid code, it doesn't break because of the type hints but it does break.
Note that this has no actual effect on what is passed, for example, this is valid code
add("hey", ["yo", 2])
This is not valid code, it doesn't break because of the type hints but it does break.
Yeah, the reason it breaks is because of the code within the function (concatenating a string with a list) not the type hints (which I think is what they meant). This should be clarified though.
@SavagePastaMan were you planning on implementing this yourself? If so, I'll go ahead and assign you.
Note that this has no actual effect on what is passed, for example, this is valid code
add("hey", ["yo", 2])
This is not valid code, it doesn't break because of the type hints but it does break.
Yeah, the reason it breaks is because of the code within the function (concatenating a string with a list) not the type hints (which I think is what they meant). This should be clarified though.
@SavagePastaMan were you planning on implementing this yourself? If so, I'll go ahead and assign you.
yeah, i can implement it. also, i can just change it to add(["Hey"], ["yo", 2])
yeah, i can implement it. also, i can just change it to
add(["Hey"], ["yo", 2])
Have assigned you :+1:
I think using two strings would be better personally (something like add("Hello", "World")
), since this is going to be targeted towards beginners who may not realise concatenation of lists is a thing.
i'll write up a short draft and we can bikeshed about stuff. would i put that in a PR to the bot repo?
i'll write up a short draft and we can bikeshed about stuff. would i put that in a PR to the bot repo?
Yeah, I'd say so. Just make sure to link this issue (Closes python-discord/meta#154.
)
If you @ me in the PR (and in #dev-contrib) I'll review it when I'm free :+1:
Lots of people wonder what at typehint is, so this tag addresses that.
Draftish: A typehint indicates to users of a function what type it expects to be passed, as well as indicating what type the return value of the function should be.
Note that this has no actual effect on what is passed, for example, this is valid code