From 3d345606f56f41ecef65e86b964d694603490c76 Mon Sep 17 00:00:00 2001 From: Ciro Date: Wed, 7 Dec 2022 12:45:19 -0300 Subject: [PATCH] Solve NoneType compatibility issue in PyPy 3.8 ImportError: cannot import name 'NoneType' from 'types' --- src/socketify/socketify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/socketify/socketify.py b/src/socketify/socketify.py index 7e38d6e..5132d57 100644 --- a/src/socketify/socketify.py +++ b/src/socketify/socketify.py @@ -18,7 +18,6 @@ from .loop import Loop from .status_codes import status_codes from .helpers import static_route from dataclasses import dataclass -from types import NoneType mimetypes.init() @@ -2308,7 +2307,7 @@ class AppListenOptions: def __post_init__(self): if not isinstance(self.port, int): raise RuntimeError("port must be an int") - if not isinstance(self.host, (NoneType, str)): + if not isinstance(self.host, (type(None), str)): raise RuntimeError("host must be a str if specified") if not isinstance(self.options, int): raise RuntimeError("options must be an int") @@ -2325,6 +2324,7 @@ class AppOptions: ssl_prefer_low_memory_usage: int = 0 def __post_init__(self): + NoneType = type(None) if not isinstance(self.key_file_name, (NoneType, str)): raise RuntimeError("key_file_name must be a str if specified") if not isinstance(self.cert_file_name, (NoneType, str)):