fix bug in placer holder (#395)
* fix bug in placer holder * remove redundent comment Co-authored-by: liukai <your_email@abc.example>pull/398/head
parent
1c03a07350
commit
c8e14e5489
|
@ -1,6 +1,4 @@
|
|||
# Copyright (c) OpenMMLab. All rights reserved.
|
||||
|
||||
|
||||
def get_placeholder(string: str) -> object:
|
||||
"""Get placeholder instance which can avoid raising errors when down-stream
|
||||
dependency is not installed properly.
|
||||
|
@ -19,13 +17,7 @@ def get_placeholder(string: str) -> object:
|
|||
raise ImportError(
|
||||
f'`{package_name}` is not installed properly, plz check.')
|
||||
|
||||
class PlaceHolderMetaclass(type):
|
||||
"""Used to support usage of PlaceHolder.xxxx."""
|
||||
|
||||
def __getattr__(self, name):
|
||||
raise_import_error(string)
|
||||
|
||||
class PlaceHolder(metaclass=PlaceHolderMetaclass):
|
||||
class PlaceHolder():
|
||||
|
||||
def __init__(self) -> None:
|
||||
raise_import_error(string)
|
||||
|
|
|
@ -12,7 +12,7 @@ class TestPlaceholder(unittest.TestCase):
|
|||
holder = get_placeholder('test')
|
||||
with pytest.raises(ImportError):
|
||||
holder()
|
||||
with pytest.raises(ImportError):
|
||||
holder.a
|
||||
with pytest.raises(ImportError):
|
||||
holder.a()
|
||||
from mmrazor.models.architectures.dynamic_ops import DynamicMixin
|
||||
|
||||
class tmp(holder, DynamicMixin):
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue