diff --git a/httplint/field/finder.py b/httplint/field/finder.py index 63dcc21..539bf00 100644 --- a/httplint/field/finder.py +++ b/httplint/field/finder.py @@ -1,4 +1,3 @@ -import importlib import sys from typing import ( @@ -82,9 +81,8 @@ def find_module(field_name: str) -> Any: name_token = HttpFieldFinder.field_aliases[name_token] try: module_name = f"httplint.field.parsers.{name_token}" - importlib.import_module(module_name) return sys.modules[module_name] - except (ImportError, KeyError, TypeError): + except (KeyError, TypeError): return None @staticmethod @@ -111,3 +109,6 @@ def parse(self, field_value: str, add_note: AddNoteMethodType) -> Any: def evaluate(self, add_note: AddNoteMethodType) -> None: return + + +import httplint.field.parsers # pylint: disable=wrong-import-position,unused-import diff --git a/httplint/field/parsers/__init__.py b/httplint/field/parsers/__init__.py index 94456ab..045c7b2 100644 --- a/httplint/field/parsers/__init__.py +++ b/httplint/field/parsers/__init__.py @@ -1 +1,8 @@ -# intentionally left blank +import importlib +import pkgutil + +__path__ = pkgutil.extend_path(__path__, __name__) +for imp, module, ispackage in pkgutil.walk_packages( + path=__path__, prefix=f"{__name__}." +): + importlib.import_module(module)