Repository: mkorpela/overrides

Issue:
@staticmethod doesn't work with @overrides

```
@staticmethod
@overrides
def get_all_statements(player_index: int) -> List[Statement]:
```

AssertionError: Method get_all_statements overrides but does not have @overrides decorator

```
@overrides
@staticmethod
def get_all_statements(player_index: int) -> List[Statement]:
```

@staticmethod
File "/Users/tyleryep/miniconda3/lib/python3.7/site-packages/overrides/overrides.py", line 57, in overrides
    for super_class in _get_base_classes(sys._getframe(2), method.__globals__):
AttributeError: 'staticmethod' object has no attribute '__globals__'



Discussion:

Patch:
diff --git a/overrides/enforce.py b/overrides/enforce.py
index 29c97ff..95e8607 100644
--- a/overrides/enforce.py
+++ b/overrides/enforce.py
@@ -27,7 +27,7 @@ class EnforceOverridesMeta(ABCMeta):
 
     @staticmethod
     def handle_special_value(value):
-        if isinstance(value, classmethod):
+        if isinstance(value, classmethod) or isinstance(value, staticmethod):
             value = value.__get__(None, dict)
         elif isinstance(value, property):
             value = value.fget


Test patch:
diff --git a/tests/test_enforce.py b/tests/test_enforce.py
index c73de72..6566684 100644
--- a/tests/test_enforce.py
+++ b/tests/test_enforce.py
@@ -22,15 +22,17 @@ class Enforcing(EnforceOverrides):
     def nonfinal_property(self):
         return "super_property"
 
+    @staticmethod
+    def nonfinal_staticmethod():
+        return "super_staticmethod"
+
     @classmethod
     def nonfinal_classmethod(cls):
         return "super_classmethod"
 
 
 class EnforceTests(unittest.TestCase):
-
     def test_enforcing_when_all_ok(self):
-
         class Subclazz(Enforcing):
             classVariableIsOk = "OK!"
 
@@ -72,6 +74,18 @@ class EnforceTests(unittest.TestCase):
         self.assertNotEqual(PropertyOverrider.nonfinal_property,
                             Enforcing.nonfinal_property)
 
+    def test_enforcing_when_staticmethod_overriden(self):
+        class StaticMethodOverrider(Enforcing):
+            @staticmethod
+            @overrides
+            def nonfinal_staticmethod():
+                return "subclass_staticmethod"
+
+        self.assertNotEqual(
+            StaticMethodOverrider.nonfinal_staticmethod(),
+            Enforcing.nonfinal_staticmethod(),
+        )
+
     def test_enforcing_when_classmethod_overriden(self):
         class ClassMethodOverrider(Enforcing):
             @classmethod