Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black formatter #158

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion flask_pymongo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,7 @@ def save_upload(filename):
content_type, _ = guess_type(filename)

storage = GridFS(self.db, base)
id = storage.put(fileobj, filename=filename, content_type=content_type, **kwargs)
id = storage.put(
fileobj, filename=filename, content_type=content_type, **kwargs
)
return id
1 change: 1 addition & 0 deletions flask_pymongo/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

if pymongo.version_tuple >= (3, 5, 0):
from bson.json_util import RELAXED_JSON_OPTIONS

DEFAULT_JSON_OPTIONS = RELAXED_JSON_OPTIONS
else:
DEFAULT_JSON_OPTIONS = None
Expand Down
1 change: 0 additions & 1 deletion flask_pymongo/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def doesnt_raise(exc=BaseException):


class FlaskPyMongoConfigTest(FlaskRequestTest):

def setUp(self):
super(FlaskPyMongoConfigTest, self).setUp()

Expand Down
3 changes: 0 additions & 3 deletions flask_pymongo/tests/test_gridfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class GridFSCleanupMixin(object):

def tearDown(self):
gridfs = GridFS(self.mongo.db)
files = list(gridfs.find())
Expand All @@ -21,7 +20,6 @@ def tearDown(self):


class TestSaveFile(GridFSCleanupMixin, FlaskPyMongoTest):

def test_it_saves_files(self):
fileobj = BytesIO(b"these are the bytes")

Expand Down Expand Up @@ -57,7 +55,6 @@ def test_it_returns_id(self):


class TestSendFile(GridFSCleanupMixin, FlaskPyMongoTest):

def setUp(self):
super(TestSendFile, self).setUp()

Expand Down
1 change: 0 additions & 1 deletion flask_pymongo/tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class JSONTest(FlaskPyMongoTest):

def test_it_encodes_json(self):
resp = jsonify({"foo": "bar"})
dumped = json.loads(ensure_str(resp.get_data()))
Expand Down
10 changes: 6 additions & 4 deletions flask_pymongo/tests/test_url_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@


class UrlConverterTest(FlaskPyMongoTest):

def test_bson_object_id_converter(self):
converter = BSONObjectIdConverter("/")

self.assertRaises(NotFound, converter.to_python, ("132"))
assert converter.to_python("4e4ac5cfffc84958fa1f45fb") == \
ObjectId("4e4ac5cfffc84958fa1f45fb")
assert converter.to_url(ObjectId("4e4ac5cfffc84958fa1f45fb")) == \
assert converter.to_python("4e4ac5cfffc84958fa1f45fb") == ObjectId(
"4e4ac5cfffc84958fa1f45fb"
)
assert (
converter.to_url(ObjectId("4e4ac5cfffc84958fa1f45fb"))
== "4e4ac5cfffc84958fa1f45fb"
)
1 change: 0 additions & 1 deletion flask_pymongo/tests/test_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class CollectionTest(FlaskPyMongoTest):

def test_find_one_or_404(self):
self.mongo.db.things.delete_many({})

Expand Down
2 changes: 0 additions & 2 deletions flask_pymongo/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def setUp(self):


class FlaskRequestTest(ToxDockerMixin, unittest.TestCase):

def setUp(self):
super(FlaskRequestTest, self).setUp()

Expand All @@ -50,7 +49,6 @@ def tearDown(self):


class FlaskPyMongoTest(FlaskRequestTest):

def setUp(self):
super(FlaskPyMongoTest, self).setUp()

Expand Down
4 changes: 1 addition & 3 deletions flask_pymongo/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ def __getitem__(self, item): # noqa: D105

class Collection(collection.Collection):

"""Sub-class of PyMongo :class:`~pymongo.collection.Collection` with helpers.

"""
"""Sub-class of PyMongo :class:`~pymongo.collection.Collection` with helpers."""

def __getattr__(self, name): # noqa: D105
attr = super(Collection, self).__getattr__(name)
Expand Down
9 changes: 6 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ deps =
pymongo312: pymongo>=3.12,<3.13

flask10: flask>=1.0,<1.1
flask10: MarkupSafe<=1.1.1
flask10: itsdangerous<=1.1.0
flask11: flask>=1.1,<1.2
flask11: MarkupSafe<=1.1.1
flask20: flask>=2.0,<2.1

commands =
Expand All @@ -34,10 +37,10 @@ skip_install = true
deps =
flake8
flake8-quotes
flake8-commas
https://github.com/dcrosta/flake8-import-order/archive/add-fromsfirst-style.tar.gz#egg=flake8-import-order
black

commands =
black {toxinidir}/flask_pymongo
flake8 [] {toxinidir}/flask_pymongo

[flake8]
Expand All @@ -46,7 +49,7 @@ inline-quotes = double
max-complexity = 7
max-line-length = 90
import-order-style = fromsfirst
ignore = D100,D104,D107
ignore = D100,D104,D107,W503
exclude =
_version.py

Expand Down