plotnine icon indicating copy to clipboard operation
plotnine copied to clipboard

fix aes argument typehint according to PEP0484

Open FFroehlich opened this issue 5 years ago • 4 comments

https://www.python.org/dev/peps/pep-0484/#arbitrary-argument-lists-and-default-argument-values

FFroehlich avatar Jun 17 '20 18:06 FFroehlich

I see the mix-up. kwargs: dict in the docstring means that kwargs is a dict, it does not say anything about the type of keys or values in the dict. The libraries in the scientific python ecosystem document keyword parameters the same way. This is different from pep-0484 were you give the type hint of the keyword parameters.

I wonder, is an IDE is interpreting kwargs: dict as a type hint for the values?

has2k1 avatar Jun 17 '20 20:06 has2k1

I see the mix-up. kwargs: dict in the docstring means that kwargs is a dict, it does not say anything about the type of keys or values in the dict. The libraries in the scientific python ecosystem document keyword parameters the same way. This is different from pep-0484 were you give the type hint of the keyword parameters.

I wonder, is an IDE is interpreting kwargs: dict as a type hint for the values?

Correct, PyCharm is interpreting this as typehint for the values. Do you believe this is an issue on their end? I see that pep-0484 doesn't really apply here, yet I would argue that the same type of type documentation is plausible here.

FFroehlich avatar Jun 18 '20 13:06 FFroehlich

Then, do you know if dict[str, object] would be treated better?

has2k1 avatar Jun 18 '20 15:06 has2k1

Then, do you know if dict[str, object] would be treated better?

It is treated the same, so it interprets that the values should be dicts.

FFroehlich avatar Jun 18 '20 20:06 FFroehlich