Skip to content

Commit 93dda8f

Browse files
committed
fix: avoid NameError on LambdaFixture.__class__ w/ PyCharm debugger
1 parent 7ea9151 commit 93dda8f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
- Add `py.typed` file to package to enable mypy static type checking
1111
- Expose minimal generic typing on `LambdaFixture`
1212

13+
### Fixed
14+
- Avoid crash when running under PyCharm/pydev debugger due to `LambdaFixture.__class__` property
15+
1316

1417
## [2.1.0] — 2022-07-17
1518
### Changed

pytest_lambda/impl.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,19 +215,22 @@ def contribute_to_parent(self, parent: Union[type, ModuleType], name: str, **kwa
215215
# To address this, we override __class__ to return LambdaFixture when the
216216
# object proxy has not yet been initialized.
217217

218-
@property
219-
def __class__(self):
218+
def _get__class__(self):
220219
try:
221220
self.__wrapped__
222221
except ValueError:
223222
return LambdaFixture
224223
else:
225224
return self.__wrapped__.__class__
226225

227-
@__class__.setter
228-
def __class__(self, val):
226+
def _set__class__(self, val):
229227
self.__wrapped__.__class__ = val
230228

229+
# NOTE: @property is avoided on __class__, as it interfered with the PyCharm/pydev debugger
230+
__class__ = property(_get__class__, _set__class__) # type: ignore[assignment]
231+
del _get__class__
232+
del _set__class__
233+
231234
# These properties are required in order to expose attributes stored on the
232235
# LambdaFixture proxying instance without prefixing them with _self_
233236

0 commit comments

Comments
 (0)