From 3dffdffd6c8ec5d9e0e7c7c404650ae372caea76 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Sat, 4 Nov 2017 14:43:29 +0100 Subject: [PATCH] Minor polish here and there --- src/attr/_make.py | 9 +++++---- tests/test_dark_magic.py | 2 +- tests/test_make.py | 7 ++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/attr/_make.py b/src/attr/_make.py index 06bf6c19..c5d63e64 100644 --- a/src/attr/_make.py +++ b/src/attr/_make.py @@ -1244,12 +1244,13 @@ def make_class(name, attrs, bases=(object,), **attributes_arguments): {} if post_init is None else {"__attrs_post_init__": post_init} ) # For pickling to work, the __module__ variable needs to be set to the - # frame where the class is created. Bypass this step in environments where + # frame where the class is created. Bypass this step in environments where # sys._getframe is not defined (Jython for example) or sys._getframe is not - # defined for arguments greater than 0 (IronPython) + # defined for arguments greater than 0 (IronPython). try: - type_.__module__ = sys._getframe(1).f_globals.get('__name__', - '__main__') + type_.__module__ = sys._getframe(1).f_globals.get( + "__name__", "__main__", + ) except (AttributeError, ValueError): pass diff --git a/tests/test_dark_magic.py b/tests/test_dark_magic.py index 30d3425f..a8e66773 100644 --- a/tests/test_dark_magic.py +++ b/tests/test_dark_magic.py @@ -103,7 +103,7 @@ class WithMetaSlots(object): pass -FromMakeClass = attr.make_class('FromMakeClass', ['x']) +FromMakeClass = attr.make_class("FromMakeClass", ["x"]) class TestDarkMagic(object): diff --git a/tests/test_make.py b/tests/test_make.py index a79372b5..55a65717 100644 --- a/tests/test_make.py +++ b/tests/test_make.py @@ -457,6 +457,7 @@ class TestMakeClass(object): attributes_arguments are passed to attributes """ C = make_class("C", ["x"], repr=False) + assert repr(C(1)).startswith("