Format the codebase using Black (#2109)
This commit: 1. Formats all of our existing code using `black`. 2. Adds a note about using `black` to `CONTRIBUTING.rst`. 3. Runs `black --check` as part of CI (failing builds that aren't properly formatted).
This commit is contained in:
		| @@ -26,15 +26,15 @@ class TestReferenceField(MongoDBTestCase): | ||||
|         # with a document class name. | ||||
|         self.assertRaises(ValidationError, ReferenceField, EmbeddedDocument) | ||||
|  | ||||
|         user = User(name='Test User') | ||||
|         user = User(name="Test User") | ||||
|  | ||||
|         # Ensure that the referenced object must have been saved | ||||
|         post1 = BlogPost(content='Chips and gravy taste good.') | ||||
|         post1 = BlogPost(content="Chips and gravy taste good.") | ||||
|         post1.author = user | ||||
|         self.assertRaises(ValidationError, post1.save) | ||||
|  | ||||
|         # Check that an invalid object type cannot be used | ||||
|         post2 = BlogPost(content='Chips and chilli taste good.') | ||||
|         post2 = BlogPost(content="Chips and chilli taste good.") | ||||
|         post1.author = post2 | ||||
|         self.assertRaises(ValidationError, post1.validate) | ||||
|  | ||||
| @@ -59,7 +59,7 @@ class TestReferenceField(MongoDBTestCase): | ||||
|  | ||||
|         class Person(Document): | ||||
|             name = StringField() | ||||
|             parent = ReferenceField('self') | ||||
|             parent = ReferenceField("self") | ||||
|  | ||||
|         Person.drop_collection() | ||||
|  | ||||
| @@ -74,7 +74,7 @@ class TestReferenceField(MongoDBTestCase): | ||||
|  | ||||
|         class Person(Document): | ||||
|             name = StringField() | ||||
|             parent = ReferenceField('self', dbref=True) | ||||
|             parent = ReferenceField("self", dbref=True) | ||||
|  | ||||
|         Person.drop_collection() | ||||
|  | ||||
| @@ -82,8 +82,8 @@ class TestReferenceField(MongoDBTestCase): | ||||
|         Person(name="Ross", parent=p1).save() | ||||
|  | ||||
|         self.assertEqual( | ||||
|             Person._get_collection().find_one({'name': 'Ross'})['parent'], | ||||
|             DBRef('person', p1.pk) | ||||
|             Person._get_collection().find_one({"name": "Ross"})["parent"], | ||||
|             DBRef("person", p1.pk), | ||||
|         ) | ||||
|  | ||||
|         p = Person.objects.get(name="Ross") | ||||
| @@ -97,21 +97,17 @@ class TestReferenceField(MongoDBTestCase): | ||||
|  | ||||
|         class Person(Document): | ||||
|             name = StringField() | ||||
|             parent = ReferenceField('self', dbref=False) | ||||
|             parent = ReferenceField("self", dbref=False) | ||||
|  | ||||
|         p = Person( | ||||
|             name='Steve', | ||||
|             parent=DBRef('person', 'abcdefghijklmnop') | ||||
|         p = Person(name="Steve", parent=DBRef("person", "abcdefghijklmnop")) | ||||
|         self.assertEqual( | ||||
|             p.to_mongo(), SON([("name", u"Steve"), ("parent", "abcdefghijklmnop")]) | ||||
|         ) | ||||
|         self.assertEqual(p.to_mongo(), SON([ | ||||
|             ('name', u'Steve'), | ||||
|             ('parent', 'abcdefghijklmnop') | ||||
|         ])) | ||||
|  | ||||
|     def test_objectid_reference_fields(self): | ||||
|         class Person(Document): | ||||
|             name = StringField() | ||||
|             parent = ReferenceField('self', dbref=False) | ||||
|             parent = ReferenceField("self", dbref=False) | ||||
|  | ||||
|         Person.drop_collection() | ||||
|  | ||||
| @@ -119,8 +115,8 @@ class TestReferenceField(MongoDBTestCase): | ||||
|         Person(name="Ross", parent=p1).save() | ||||
|  | ||||
|         col = Person._get_collection() | ||||
|         data = col.find_one({'name': 'Ross'}) | ||||
|         self.assertEqual(data['parent'], p1.pk) | ||||
|         data = col.find_one({"name": "Ross"}) | ||||
|         self.assertEqual(data["parent"], p1.pk) | ||||
|  | ||||
|         p = Person.objects.get(name="Ross") | ||||
|         self.assertEqual(p.parent, p1) | ||||
| @@ -128,9 +124,10 @@ class TestReferenceField(MongoDBTestCase): | ||||
|     def test_undefined_reference(self): | ||||
|         """Ensure that ReferenceFields may reference undefined Documents. | ||||
|         """ | ||||
|  | ||||
|         class Product(Document): | ||||
|             name = StringField() | ||||
|             company = ReferenceField('Company') | ||||
|             company = ReferenceField("Company") | ||||
|  | ||||
|         class Company(Document): | ||||
|             name = StringField() | ||||
| @@ -138,12 +135,12 @@ class TestReferenceField(MongoDBTestCase): | ||||
|         Product.drop_collection() | ||||
|         Company.drop_collection() | ||||
|  | ||||
|         ten_gen = Company(name='10gen') | ||||
|         ten_gen = Company(name="10gen") | ||||
|         ten_gen.save() | ||||
|         mongodb = Product(name='MongoDB', company=ten_gen) | ||||
|         mongodb = Product(name="MongoDB", company=ten_gen) | ||||
|         mongodb.save() | ||||
|  | ||||
|         me = Product(name='MongoEngine') | ||||
|         me = Product(name="MongoEngine") | ||||
|         me.save() | ||||
|  | ||||
|         obj = Product.objects(company=ten_gen).first() | ||||
| @@ -160,6 +157,7 @@ class TestReferenceField(MongoDBTestCase): | ||||
|         """Ensure that ReferenceFields can be queried using objects and values | ||||
|         of the type of the primary key of the referenced object. | ||||
|         """ | ||||
|  | ||||
|         class Member(Document): | ||||
|             user_num = IntField(primary_key=True) | ||||
|  | ||||
| @@ -175,10 +173,10 @@ class TestReferenceField(MongoDBTestCase): | ||||
|         m2 = Member(user_num=2) | ||||
|         m2.save() | ||||
|  | ||||
|         post1 = BlogPost(title='post 1', author=m1) | ||||
|         post1 = BlogPost(title="post 1", author=m1) | ||||
|         post1.save() | ||||
|  | ||||
|         post2 = BlogPost(title='post 2', author=m2) | ||||
|         post2 = BlogPost(title="post 2", author=m2) | ||||
|         post2.save() | ||||
|  | ||||
|         post = BlogPost.objects(author=m1).first() | ||||
| @@ -191,6 +189,7 @@ class TestReferenceField(MongoDBTestCase): | ||||
|         """Ensure that ReferenceFields can be queried using objects and values | ||||
|         of the type of the primary key of the referenced object. | ||||
|         """ | ||||
|  | ||||
|         class Member(Document): | ||||
|             user_num = IntField(primary_key=True) | ||||
|  | ||||
| @@ -206,10 +205,10 @@ class TestReferenceField(MongoDBTestCase): | ||||
|         m2 = Member(user_num=2) | ||||
|         m2.save() | ||||
|  | ||||
|         post1 = BlogPost(title='post 1', author=m1) | ||||
|         post1 = BlogPost(title="post 1", author=m1) | ||||
|         post1.save() | ||||
|  | ||||
|         post2 = BlogPost(title='post 2', author=m2) | ||||
|         post2 = BlogPost(title="post 2", author=m2) | ||||
|         post2.save() | ||||
|  | ||||
|         post = BlogPost.objects(author=m1).first() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user