Skip to content

Commit

Permalink
support for staticmethod
Browse files Browse the repository at this point in the history
  • Loading branch information
obriencj committed Jul 6, 2024
1 parent febabb9 commit 3ad6ae3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions preoccupied/proxytype/mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ def decorate_proxytype(wrap: TypeInfo, orig: Instance, virt: Instance):
nsym.node = clone_overloaded(node, wrap, virt)
wrap.names[name] = nsym

elif isinstance(node, Decorator):
nsym = sym.copy()
nsym.node = clone_decorator(node, wrap, virt)
wrap.names[name] = nsym

else:
# ignore others
pass
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[metadata]

name = preoccupied.proxytype
version = 0.3.0
version = 0.4.0
description = static typing support for dynamic proxy classes

author = Christopher O'Brien
Expand Down Expand Up @@ -83,7 +83,7 @@ download = True
basepython = python3.9

commands =
python -B -I -m nose
python -B -I -m nose -s

download = True

Expand Down
4 changes: 4 additions & 0 deletions tests/data/binary.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class Normal:
def getName(self) -> str:
...

@staticmethod
def getStatic() -> int:
...


RT = TypeVar("RT")

Expand Down
4 changes: 4 additions & 0 deletions tests/data/unary.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class Normal:
def getName(self) -> str:
...

@staticmethod
def getStatic() -> int:
...


@proxytype(Normal)
class Delayed:
Expand Down
8 changes: 8 additions & 0 deletions tests/mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ def test_plugin_disabled(self):
self.assertIn("doSomething", normal.names)
self.assertIn("doAnother", normal.names)
self.assertIn("getName", normal.names)
self.assertIn("getStatic", normal.names)

self.assertNotIn("doSomething", delayed.names)
self.assertNotIn("doAnother", delayed.names)
self.assertIn("getName", delayed.names)
self.assertNotIn("getStatic", delayed.names)


def test_plugin_enabled(self):
Expand All @@ -89,10 +91,12 @@ def test_plugin_enabled(self):
self.assertIn("doSomething", normal.names)
self.assertIn("doAnother", normal.names)
self.assertIn("getName", normal.names)
self.assertIn("getStatic", normal.names)

self.assertIn("doSomething", delayed.names)
self.assertIn("doAnother", delayed.names)
self.assertIn("getName", delayed.names)
self.assertIn("getStatic", delayed.names)


class UnaryTest(TestCase):
Expand All @@ -115,10 +119,12 @@ def test_plugin_disabled(self):
self.assertIn("doSomething", normal.names)
self.assertIn("doAnother", normal.names)
self.assertIn("getName", normal.names)
self.assertIn("getStatic", normal.names)

self.assertNotIn("doSomething", delayed.names)
self.assertNotIn("doAnother", delayed.names)
self.assertIn("getName", delayed.names)
self.assertNotIn("getStatic", delayed.names)


def test_plugin_enabled(self):
Expand All @@ -133,10 +139,12 @@ def test_plugin_enabled(self):
self.assertIn("doSomething", normal.names)
self.assertIn("doAnother", normal.names)
self.assertIn("getName", normal.names)
self.assertIn("getStatic", normal.names)

self.assertIn("doSomething", delayed.names)
self.assertIn("doAnother", delayed.names)
self.assertIn("getName", delayed.names)
self.assertIn("getStatic", delayed.names)


# The end.

0 comments on commit 3ad6ae3

Please sign in to comment.