marshmallow icon indicating copy to clipboard operation
marshmallow copied to clipboard

Add return type to `fields.Email.__init__` so that it's not untyped

Open kkirsche opened this issue 1 year ago • 2 comments

This merge request adds a type hint to fields.Email's `init method to avoid no untyped call errors in mypy for library consumers.

kkirsche avatar Jul 25 '22 17:07 kkirsche

Is this specific to Email field?

lafrech avatar Jul 25 '22 19:07 lafrech

This was the only field from marshmallow in my codebase that was triggering this mypy behavior. I'm not sure if any others do though

kkirsche avatar Jul 25 '22 20:07 kkirsche

From those discussions

  • https://github.com/python/mypy/issues/3358
  • https://github.com/python/mypy/issues/604
  • https://github.com/python/mypy/pull/5677

Explicit -> None is needed if init func has no argument. I guess *args and **kwargs don't count.

Form a quick check, Email is the only concerned field. Although IPInterface.__init__ lacks typing (fixed in #2036).

lafrech avatar Aug 18 '22 14:08 lafrech

Thank you :) I can look at expanding types if you are interested in a future PR, I just wasn't sure what the responsiveness of the team was, so I was rather hesitant to expand the scope too far.

kkirsche avatar Aug 22 '22 20:08 kkirsche

Well, don't expect us to be quick to review and merge (see current backlog), but quality PRs are absolutely welcome.

(And if you're good at type hinting, I wouldn't mind a helping hand for #1896.)

Thanks!

lafrech avatar Aug 22 '22 20:08 lafrech

Course, I'll take a look when I have a few moments. I've been trying to work a lot more lately with the typeshed team to get feedback from the source about how to use type hints correctly and effectively, so I'm happy to see if I may be able to assist with that. I'll need to pull it down and run mypy against it as currently it looks like the build log was deleted, so can't view the historic error from mypy

kkirsche avatar Aug 22 '22 20:08 kkirsche