[issue45900] Type annotations needed for convenience functions in ipaddress module

2021-11-25 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Typing for stdlib is provided by https://github.com/python/typeshed
CPython policy discourages embedded typing declarations.

--
nosy: +asvetlov
resolution:  -> rejected
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45900] Type annotations needed for convenience functions in ipaddress module

2021-11-25 Thread William George


Change by William George :


--
keywords: +patch
pull_requests: +28015
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/29778

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45900] Type annotations needed for convenience functions in ipaddress module

2021-11-25 Thread William George


New submission from William George :

The convenience factory functions in the ipaddress module each return one of 
two types (IPv4Network vs IPv6Network, etc).  Modern code wants to be friendly 
to either stack, and these functions are great at enabling that, but current 
implementation blocks type inference for most (all?) IDEs.

Proposal is easy enough, specifying return type of e.g. `Union[IPv4Network, 
IPv6Network]` for these factory functions.  

I believe the rest of the public interface for this module is unambiguous 
enough that annotations aren't needed, but if others see value they could be 
added easily enough.

For some of these there exists a version-independent base class that could be 
referenced instead of a union, but it's not clear to me how well IDEs will 
actually honor such an annotation referencing an internal class 
(single-underscore).  My limited testing of that didn't work well and there's 
no such base class for the Interface classes anyway. 

PR for this incomming.

--
components: Library (Lib)
messages: 407005
nosy: pmoody, wrgeorge1983
priority: normal
severity: normal
status: open
title: Type annotations needed for convenience functions in ipaddress module
type: enhancement
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com