diff --git a/splinter/cookie_manager.py b/splinter/cookie_manager.py index bbd64bc95..a2ed6bd0f 100644 --- a/splinter/cookie_manager.py +++ b/splinter/cookie_manager.py @@ -1,10 +1,9 @@ # Copyright 2012 splinter authors. All rights reserved. # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. -from splinter.meta import InheritedDocs -class CookieManagerAPI(InheritedDocs("_CookieManagerAPI", (object,), {})): # type: ignore +class CookieManagerAPI: """An API that specifies how a splinter driver deals with cookies. You can add cookies using the :meth:`add ` method, diff --git a/splinter/driver/__init__.py b/splinter/driver/__init__.py index 3689b8352..05dfc7dcd 100644 --- a/splinter/driver/__init__.py +++ b/splinter/driver/__init__.py @@ -10,10 +10,9 @@ from splinter.cookie_manager import CookieManagerAPI from splinter.element_list import ElementList -from splinter.meta import InheritedDocs -class DriverAPI(InheritedDocs("_DriverAPI", (object,), {})): # type: ignore +class DriverAPI: """ Basic driver API class. """ @@ -730,7 +729,7 @@ def cookies(self) -> Type[CookieManagerAPI]: ) -class ElementAPI(InheritedDocs("_ElementAPI", (object,), {})): # type: ignore +class ElementAPI: """ Basic element API class. diff --git a/splinter/meta.py b/splinter/meta.py deleted file mode 100644 index 30e4bcb35..000000000 --- a/splinter/meta.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2012 splinter authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - - -class InheritedDocs(type): - def __new__( - mcs, - class_name: str, - bases: tuple, - dict: dict, - ) -> type: # NOQA: N804, A002 - """Metaclass that forces inheritance of docstrings.""" - items_to_patch = [(k, v) for k, v in dict.items() if not k.startswith("__") and not v.__doc__] - for name, obj in items_to_patch: - doc = None - for base in bases: - if hasattr(base, name): - doc = getattr(base, name).__doc__ - - if doc: - if isinstance(obj, property) and not obj.fset: - obj.fget.__doc__ = doc - dict[name] = property(fget=obj.fget) - else: - obj.__doc__ = doc - break - - return type.__new__(mcs, class_name, bases, dict) diff --git a/tests/test_meta.py b/tests/test_meta.py deleted file mode 100644 index 5b19d45d4..000000000 --- a/tests/test_meta.py +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright 2013 splinter authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. -import unittest - -from splinter.meta import InheritedDocs - - -class SuperClass(InheritedDocs("_SuperClass", (object,), {})): - def say_hello(self): - """ - Says hello - """ - pass - - -class SubClass(SuperClass): - def say_hello(self): - print("hello") - - @property - def name(self): - """ - Stores the name - """ - pass - - -class SubSubClass(SubClass): - def say_hello(self): - print("I can't say hello") - - say_hi = say_hello - - @property - def name(self): - pass - - -class MetaTest(unittest.TestCase): - def test_should_include_docs_from_superclass(self): - "should include doc from superclass" - self.assertEqual(SuperClass.say_hello.__doc__, SubClass.say_hello.__doc__) - - def test_should_include_docs_from_any_class_in_hierarchy(self): - "should include doc from any class in hierarchy" - self.assertEqual(SuperClass.say_hello.__doc__, SubSubClass.say_hello.__doc__) - - def test_change_docs_for_readonly_properties(self): - "should also change docs for readonly properties" - self.assertEqual(SubClass.name.__doc__, SubSubClass.name.__doc__) - - def test_should_not_touch_the_class_type(self): - "shouldn't touch the type of the object" - self.assertEqual("SubSubClass", SubSubClass.__name__)