Skip to content

Commit 7736a0c

Browse files
committed
style(ruff): initial support
1 parent d9a72aa commit 7736a0c

File tree

19 files changed

+309
-77
lines changed

19 files changed

+309
-77
lines changed

.github/workflows/testing.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
- name: Pre-commit
2929
run: |
3030
pre-commit run --all-files
31+
- name: Run Ruff
32+
run: ruff check --output-format=github .
3133
- name: Test with pytest
3234
run: |
3335
pytest

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ Session.vim
6060
# virtualenv
6161
.venv*
6262
venv*
63-
src/
63+
src/

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
default_language_version:
2+
python: python3.8
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.5.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- repo: https://github.com/commitizen-tools/commitizen
12+
rev: v2.42.1
13+
hooks:
14+
- id: commitizen

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ help:
1717
# Catch-all target: route all unknown targets to Sphinx using the new
1818
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1919
%: Makefile
20-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
<p class="logo"><a href="{{ pathto(master_doc) }}">
22
<img class="logo" src="https://raw.githubusercontent.com/numberly/flask-stupe/master/artwork/stupeflask.png" alt="Logo"/>
33
</a></p>
4-

flask_stupe/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ def register_blueprints(self, package, **options):
6161
It means that if a file called `foo.py` has an exportable variable
6262
called `foo`, it will try to register that variable as a blueprint.
6363
"""
64-
prefix = package.__name__ + '.'
64+
prefix = package.__name__ + "."
6565
for importer, name, is_pkg in iter_modules(package.__path__, prefix):
6666
module = importer.find_module(name).load_module(name)
67-
blueprint_name = name.rsplit('.')[-1]
67+
blueprint_name = name.rsplit(".")[-1]
6868
blueprint = getattr(module, blueprint_name, None)
6969
if blueprint and isinstance(blueprint, Blueprint):
70-
log.info(' * Registering blueprint {}'.format(name))
70+
log.info(" * Registering blueprint {}".format(name))
7171
blueprint.name = name
7272
self.register_blueprint(blueprint, **options)
7373
elif is_pkg:

flask_stupe/auth.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ def get_user():
2222
A view decorated with :func:`auth_required` will be aborted with a status
2323
code 401 if the user making the request is not authenticated.
2424
"""
25+
2526
@functools.wraps(function)
2627
def __inner(*args, **kwargs):
2728
if not request.user:
2829
abort(401)
2930
return function(*args, **kwargs)
31+
3032
return __inner
3133

3234

@@ -47,6 +49,7 @@ def permission_required(*permissions):
4749
You can apply this decorator multiple times if you need several permissions
4850
at once to access a view.
4951
"""
52+
5053
def __decorator(function):
5154
@functools.wraps(function)
5255
def __inner(*args, **kwargs):
@@ -59,7 +62,9 @@ def __inner(*args, **kwargs):
5962
if fnmatch.filter(permissions, user_group):
6063
return function(*args, **kwargs)
6164
abort(403)
65+
6266
return auth_required(__inner)
67+
6368
return __decorator
6469

6570

flask_stupe/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def _str2list(v):
1414

1515

1616
class Config(FlaskConfig):
17-
1817
def from_env(self):
1918
"""Try to overload the config with the environment.
2019

flask_stupe/converters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77

88
if bson:
9+
910
class ObjectIdConverter(BaseConverter):
10-
regex = r'[A-Fa-f0-9]{24}'
11+
regex = r"[A-Fa-f0-9]{24}"
1112

1213
def to_python(self, value):
1314
return bson.ObjectId(value)

0 commit comments

Comments
 (0)