elWanderero · GitHub

Documentation

(And also for ipaddress.IPv6Network.hosts())

In https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv4Network.hosts and https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv6Network.hosts the hosts() method is documented as returning an iterator, when in reality it can return an iterator or a list.

This extra return possibilty can be seen in

self.hosts = lambda: [IPv4Address(addr)]

and

self.hosts = lambda: [IPv6Address(addr)]

and was introduced in 2020 in

8e9c47a

, but was fixed only recently in typeshed:

python/typeshed@ c0fed91

Linked PRs

Read the original on github.com ↗