Skip to content

Commit

Permalink
Apply pyupgrade --py36-plus on code base
Browse files Browse the repository at this point in the history
modified:   .pre-commit-config.yaml
modified:   setup.py
modified:   src/flask_uploads/extensions.py
modified:   src/flask_uploads/flask_uploads.py
modified:   src/flask_uploads/test_helper.py
modified:   tests/test_flask_reuploaded.py
  • Loading branch information
jugmac00 committed Jul 3, 2020
1 parent 1983ad8 commit 1f200cd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ repos:
rev: 3.8.3
hooks:
- id: flake8

- repo: https://github.com/asottile/pyupgrade
rev: v2.4.1
hooks:
- id: pyupgrade
args: [--py36-plus]
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import codecs
import os

Expand Down
5 changes: 2 additions & 3 deletions src/flask_uploads/extensions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

"""Extension presets and extension configuration."""
import os

Expand Down Expand Up @@ -63,7 +62,7 @@
DEFAULTS = TEXT + DOCUMENTS + IMAGES + DATA


class All(object):
class All:
"""
This type can be used to allow all extensions. There is a predefined
instance named `ALL`.
Expand All @@ -77,7 +76,7 @@ def __contains__(self, item):
ALL = All()


class AllExcept(object):
class AllExcept:
"""
This can be used to allow all file types except certain ones. For example,
to ban .exe and .iso files, pass::
Expand Down
5 changes: 2 additions & 3 deletions src/flask_uploads/flask_uploads.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
flaskext.uploads
================
Expand Down Expand Up @@ -106,7 +105,7 @@ def configure_uploads(app, upload_sets):
app.register_blueprint(uploads_mod)


class UploadConfiguration(object):
class UploadConfiguration:
"""
This holds the configuration for a single `UploadSet`. The constructor's
arguments are also the attributes.
Expand Down Expand Up @@ -134,7 +133,7 @@ def __eq__(self, other):
return self.tuple == other.tuple


class UploadSet(object):
class UploadSet:
"""
This represents a single set of uploaded files. Each upload set is
independent of the others. This can be reused across multiple application
Expand Down
9 changes: 1 addition & 8 deletions src/flask_uploads/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@
- it has to be importable
- it can't be moved in the tests directory
"""
import sys

from werkzeug.datastructures import FileStorage

if sys.version_info < (3,): # python 2
string_types = basestring, # noqa: F821
else: # python 3
string_types = str,


class TestingFileStorage(FileStorage):
"""
Expand Down Expand Up @@ -51,7 +44,7 @@ def save(self, dst, buffer_size=16384):
:param dst: The file to save to.
:param buffer_size: Ignored.
"""
if isinstance(dst, string_types):
if isinstance(dst, str):
self.saved = dst
else:
self.saved = dst.name
14 changes: 6 additions & 8 deletions tests/test_flask_reuploaded.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# -*- coding: utf-8 -*-
"""
:copyright: 2010 Matthew "LeafStorm" Frazier
:license: MIT/X11, see LICENSE for details
"""
from __future__ import with_statement

import os
import os.path
Expand All @@ -22,7 +20,7 @@
from flask_uploads import lowercase_ext


class TestMiscellaneous(object):
class TestMiscellaneous:
def test_tfs(self):
tfs = TestingFileStorage(filename='foo.bar')
assert tfs.filename == 'foo.bar'
Expand Down Expand Up @@ -68,7 +66,7 @@ def test_custom_iterables(self):
Config = UploadConfiguration


class TestConfiguration(object):
class TestConfiguration:
def setup(self):
self.app = Flask(__name__)

Expand Down Expand Up @@ -157,7 +155,7 @@ def test_default_destination_callable(self):
assert photo_conf == Config('/mnt/photos', 'http://localhost:6002/')


class TestPreconditions(object):
class TestPreconditions:
def test_filenames(self):
uset = UploadSet('files')
uset._config = Config('/uploads')
Expand All @@ -178,7 +176,7 @@ def test_default_extensions(self):
assert uset.extension_allowed(ext) is result


class TestSaving(object):
class TestSaving:
def setup(self):
self.old_makedirs = os.makedirs
os.makedirs = lambda v: None
Expand Down Expand Up @@ -260,7 +258,7 @@ def test_storage_is_not_a_werkzeug_datastructure(self):
uset.save(non_storage)


class TestConflictResolution(object):
class TestConflictResolution:
def setup(self):
self.extant_files = []
self.old_exists = os.path.exists
Expand Down Expand Up @@ -311,7 +309,7 @@ def test_conflict_without_extension(self):
assert res == 'foo_1'


class TestPathsAndURLs(object):
class TestPathsAndURLs:
def test_path(self):
uset = UploadSet('files')
uset._config = Config('/uploads')
Expand Down

0 comments on commit 1f200cd

Please sign in to comment.