Simplify props.py

It had code for handling the differences between old-style and new-style classes in Python 2, but support for Python 2 was dropped long ago.
This commit is contained in:
Rob Percival 2023-07-04 16:14:10 +01:00 committed by GitHub
parent 03cf2e131e
commit 6d609db8c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,15 +1,11 @@
class _OldClass:
class _Class:
pass
class _NewClass:
pass
_all_vars = set(dir(_OldClass) + dir(_NewClass))
_built_in_vars = set(dir(_Class))
def props(x):
return {
key: vars(x).get(key, getattr(x, key)) for key in dir(x) if key not in _all_vars
key: vars(x).get(key, getattr(x, key)) for key in dir(x) if key not in _built_in_vars
}