From a6d330c5e91a8e5c99f95d54ec63f302efefc670 Mon Sep 17 00:00:00 2001 From: mavaylon1 Date: Wed, 3 Apr 2024 15:07:46 -0700 Subject: [PATCH] typing --- src/hdmf/build/classgenerator.py | 3 ++- src/hdmf/build/manager.py | 4 ++-- src/hdmf/common/__init__.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/hdmf/build/classgenerator.py b/src/hdmf/build/classgenerator.py index 769c2b1c6..dc648be42 100644 --- a/src/hdmf/build/classgenerator.py +++ b/src/hdmf/build/classgenerator.py @@ -1,6 +1,7 @@ from copy import deepcopy from datetime import datetime, date import types +import typing import numpy as np @@ -36,7 +37,7 @@ def register_generator(self, **kwargs): {'name': 'spec', 'type': BaseStorageSpec, 'doc': ''}, {'name': 'parent_cls', 'type': type, 'doc': ''}, {'name': 'attr_names', 'type': dict, 'doc': ''}, - {'name': 'post_init_method', 'type': types.Callable, 'default': None, + {'name': 'post_init_method', 'type': typing.Callable, 'default': None, 'doc': 'The function used as a post_init method to validate the class generation.'}, {'name': 'type_map', 'type': 'hdmf.build.manager.TypeMap', 'doc': ''}, returns='the class for the given namespace and data_type', rtype=type) diff --git a/src/hdmf/build/manager.py b/src/hdmf/build/manager.py index 03056ae2b..b845a08cb 100644 --- a/src/hdmf/build/manager.py +++ b/src/hdmf/build/manager.py @@ -1,7 +1,7 @@ import logging from collections import OrderedDict, deque from copy import copy -import types +import typing from .builders import DatasetBuilder, GroupBuilder, LinkBuilder, Builder, BaseBuilder from .classgenerator import ClassGenerator, CustomClassGenerator, MCIClassGenerator @@ -505,7 +505,7 @@ def get_container_cls(self, **kwargs): @docval({"name": "data_type", "type": str, "doc": "the data type to create a AbstractContainer class for"}, {"name": "namespace", "type": str, "doc": "the namespace containing the data_type", "default": None}, - {'name': 'post_init_method', 'type': types.Callable, 'default': None, + {'name': 'post_init_method', 'type': typing.Callable, 'default': None, 'doc': 'The function used as a post_init method to validate the class generation.'}, {"name": "autogen", "type": bool, "doc": "autogenerate class if one does not exist", "default": True}, returns='the class for the given namespace and data_type', rtype=type) diff --git a/src/hdmf/common/__init__.py b/src/hdmf/common/__init__.py index 2e0ea86ac..dce5295b3 100644 --- a/src/hdmf/common/__init__.py +++ b/src/hdmf/common/__init__.py @@ -3,7 +3,7 @@ ''' import os.path from copy import deepcopy -import types +import typing CORE_NAMESPACE = 'hdmf-common' EXP_NAMESPACE = 'hdmf-experimental' @@ -137,7 +137,7 @@ def available_namespaces(): @docval({'name': 'data_type', 'type': str, 'doc': 'the data_type to get the Container class for'}, {'name': 'namespace', 'type': str, 'doc': 'the namespace the data_type is defined in'}, - {'name': 'post_init_method', 'type': types.Callable, 'default': None, + {'name': 'post_init_method', 'type': typing.Callable, 'default': None, 'doc': 'The function used as a post_init method to validate the class generation.'}, {"name": "autogen", "type": bool, "doc": "autogenerate class if one does not exist", "default": True}, is_method=False)