mirror of
https://github.com/certbot/certbot.git
synced 2026-07-31 18:34:41 +02:00
fixup fromstring return types (#10162)
in https://github.com/certbot/certbot/pull/9124 we had the problem of certbot-nginx's `Addr.fromstring` method possibly returning None which is not possible in the `Addr` method in the certbot base class or in certbot-apache. we fixed this by telling mypy the common `Addr.fromstring` method returns an `Optional[Addr]` (despite it actually always returning an `Addr`) and then unnecessarily complicating certbot-apache's code a bit. the need for extra complexity with this approach is going even further in https://github.com/certbot/certbot/pull/10151 where we have to use `cast` to assure mypy that the type isn't actually `Optional`. i personally don't like all this
This commit is contained in:
@@ -261,7 +261,7 @@ class Addr:
|
||||
self.ipv6 = ipv6
|
||||
|
||||
@classmethod
|
||||
def fromstring(cls: Type[GenericAddr], str_addr: str) -> Optional[GenericAddr]:
|
||||
def fromstring(cls: Type[GenericAddr], str_addr: str) -> GenericAddr:
|
||||
"""Initialize Addr from string."""
|
||||
if str_addr.startswith('['):
|
||||
# ipv6 addresses starts with [
|
||||
|
||||
Reference in New Issue
Block a user