Skip to content

Commit

Permalink
chore: use isort instead of reoder-python-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Mar 13, 2024
1 parent 43404ff commit 31a70d4
Show file tree
Hide file tree
Showing 26 changed files with 72 additions and 59 deletions.
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ repos:
- id: end-of-file-fixer
exclude: "\\.svg$|\\.map$|\\.min\\.css$|\\.min\\.js$|\\.po$|\\.pot$"
- id: check-toml
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.12.0
- repo: https://github.com/pycqa/isort
rev: "5.13.2"
hooks:
- id: reorder-python-imports
args: ["--application-directories", "b3desk"]
- id: isort
name: isort (python)
args: ["--force-single-line-imports", "--line-length", "120"]
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
Expand Down
13 changes: 7 additions & 6 deletions web/b3desk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import logging
import os

from b3desk.settings import MainSettings
from b3desk.utils import is_rie
from flask import Flask
from flask import render_template
from flask import request
Expand All @@ -25,6 +23,9 @@
from flask_wtf.csrf import CSRFProtect
from jinja2 import StrictUndefined

from b3desk.settings import MainSettings
from b3desk.utils import is_rie

from .utils import model_converter

__version__ = "1.1.3"
Expand Down Expand Up @@ -107,8 +108,8 @@ def setup_database(app):


def setup_jinja(app):
from b3desk.session import has_user_session
from b3desk.session import get_current_user
from b3desk.session import has_user_session

if app.debug or app.testing:
app.jinja_env.undefined = StrictUndefined
Expand Down Expand Up @@ -168,11 +169,11 @@ def internal_error(error):

def setup_endpoints(app):
with app.app_context():
import b3desk.endpoints.public
import b3desk.endpoints.join
import b3desk.endpoints.meetings
import b3desk.endpoints.api
import b3desk.endpoints.join
import b3desk.endpoints.meeting_files
import b3desk.endpoints.meetings
import b3desk.endpoints.public

app.register_blueprint(b3desk.endpoints.public.bp)
app.register_blueprint(b3desk.endpoints.join.bp)
Expand Down
4 changes: 2 additions & 2 deletions web/b3desk/endpoints/api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from b3desk.models.users import get_or_create_user
from flask import Blueprint
from flask import request

from .. import auth
from b3desk.models.users import get_or_create_user

from .. import auth

bp = Blueprint("api", __name__)

Expand Down
16 changes: 8 additions & 8 deletions web/b3desk/endpoints/join.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
from datetime import datetime

from b3desk.forms import JoinMailMeetingForm
from b3desk.forms import JoinMeetingForm
from b3desk.models import db
from b3desk.models.meetings import get_mail_meeting
from b3desk.models.meetings import get_meeting_from_meeting_id_and_user_id
from b3desk.models.meetings import Meeting
from flask import abort
from flask import Blueprint
from flask import abort
from flask import current_app
from flask import flash
from flask import redirect
Expand All @@ -16,13 +10,19 @@
from flask import url_for
from flask_babel import lazy_gettext as _

from b3desk.forms import JoinMailMeetingForm
from b3desk.forms import JoinMeetingForm
from b3desk.models import db
from b3desk.models.meetings import Meeting
from b3desk.models.meetings import get_mail_meeting
from b3desk.models.meetings import get_meeting_from_meeting_id_and_user_id

from .. import auth
from ..session import get_authenticated_attendee_fullname
from ..session import get_current_user
from ..session import has_user_session
from ..session import meeting_owner_needed


bp = Blueprint("join", __name__)


Expand Down
14 changes: 7 additions & 7 deletions web/b3desk/endpoints/meeting_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@

import filetype
import requests
from b3desk.forms import MeetingFilesForm
from b3desk.models import db
from b3desk.models.meetings import Meeting
from b3desk.models.meetings import MeetingFiles
from b3desk.models.meetings import MeetingFilesExternal
from flask import abort
from flask import Blueprint
from flask import abort
from flask import current_app
from flask import flash
from flask import jsonify
Expand All @@ -30,11 +25,16 @@
from webdav3.exceptions import WebDavException
from werkzeug.utils import secure_filename

from b3desk.forms import MeetingFilesForm
from b3desk.models import db
from b3desk.models.meetings import Meeting
from b3desk.models.meetings import MeetingFiles
from b3desk.models.meetings import MeetingFilesExternal

from .. import auth
from ..session import get_current_user
from ..session import meeting_owner_needed


bp = Blueprint("meeting_files", __name__)


Expand Down
22 changes: 11 additions & 11 deletions web/b3desk/endpoints/meetings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,8 @@
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.
from b3desk.forms import EndMeetingForm
from b3desk.forms import MeetingForm
from b3desk.forms import MeetingWithRecordForm
from b3desk.forms import RecordingForm
from b3desk.forms import ShowMeetingForm
from b3desk.models import db
from b3desk.models.meetings import get_quick_meeting_from_user_and_random_string
from b3desk.models.meetings import Meeting
from b3desk.models.users import User
from flask import abort
from flask import Blueprint
from flask import abort
from flask import current_app
from flask import flash
from flask import redirect
Expand All @@ -27,14 +18,23 @@
from flask import url_for
from flask_babel import lazy_gettext as _

from b3desk.forms import EndMeetingForm
from b3desk.forms import MeetingForm
from b3desk.forms import MeetingWithRecordForm
from b3desk.forms import RecordingForm
from b3desk.forms import ShowMeetingForm
from b3desk.models import db
from b3desk.models.meetings import Meeting
from b3desk.models.meetings import get_quick_meeting_from_user_and_random_string
from b3desk.models.users import User

from .. import auth
from ..session import get_current_user
from ..session import meeting_owner_needed
from ..utils import is_accepted_email
from ..utils import is_valid_email
from ..utils import send_quick_meeting_mail


bp = Blueprint("meetings", __name__)


Expand Down
1 change: 0 additions & 1 deletion web/b3desk/endpoints/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ..templates.content import FAQ_CONTENT
from .meetings import meeting_mailto_params


bp = Blueprint("public", __name__)


Expand Down
3 changes: 2 additions & 1 deletion web/b3desk/models/bbb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
from xml.etree import ElementTree

import requests
from b3desk.tasks import background_upload
from flask import current_app
from flask import render_template
from flask import url_for

from b3desk.tasks import background_upload


class BBB:
"""Interface to BBB API."""
Expand Down
5 changes: 3 additions & 2 deletions web/b3desk/models/meetings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
from datetime import datetime
from datetime import timedelta

from b3desk.utils import get_random_alphanumeric_string
from b3desk.utils import secret_key
from flask import current_app
from flask import url_for
from sqlalchemy_utils import StringEncryptedType

from b3desk.utils import get_random_alphanumeric_string
from b3desk.utils import secret_key

from . import db
from .users import User

Expand Down
3 changes: 2 additions & 1 deletion web/b3desk/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
from urllib.parse import urlunparse

import requests
from b3desk.utils import secret_key
from flask import current_app

from b3desk.utils import secret_key

from . import db


Expand Down
3 changes: 2 additions & 1 deletion web/b3desk/session.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from functools import wraps

from b3desk.models.users import get_or_create_user
from flask import abort
from flask import current_app
from flask import g
from flask import session
from flask_pyoidc.user_session import UserSession

from b3desk.models.users import get_or_create_user


def get_current_user():
if "user" not in g:
Expand Down
5 changes: 3 additions & 2 deletions web/b3desk/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
from typing import List
from typing import Optional

from b3desk.constants import DEFAULT_EMAIL_WHITELIST
from flask_babel import lazy_gettext as _
from pydantic import ValidationInfo
from pydantic import computed_field
from pydantic import field_validator
from pydantic import ValidationInfo
from pydantic_settings import BaseSettings
from pydantic_settings import SettingsConfigDict

from b3desk.constants import DEFAULT_EMAIL_WHITELIST

AVAILABLE_WORDINGS = {
"MEETING": {"cours": "cours", "reunion": "réunion", "seminaire": "séminaire"},
"MEETINGS": {"cours": "cours", "reunion": "réunions", "seminaire": "séminaires"},
Expand Down
3 changes: 2 additions & 1 deletion web/b3desk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from email.message import EmailMessage
from email.mime.text import MIMEText

from b3desk.models import db
from flask import abort
from flask import current_app
from flask import render_template
Expand All @@ -15,6 +14,8 @@
from netaddr import IPNetwork
from werkzeug.routing import BaseConverter

from b3desk.models import db


def secret_key():
return current_app.config["SECRET_KEY"]
Expand Down
2 changes: 1 addition & 1 deletion web/migrations/alembic_helpers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Code based on https://github.com/talkpython/data-driven-web-apps-with-flask
from alembic import op
from sqlalchemy import engine_from_config
from sqlalchemy import MetaData
from sqlalchemy import engine_from_config


def load_schema():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Revises: 8fe077ecfb10
Create Date: 2023-02-28 14:30:43.642893
"""

import os
import sys

Expand All @@ -16,7 +17,6 @@

import alembic_helpers


# revision identifiers, used by Alembic.
revision = "1094e771bd3f"
down_revision = "8fe077ecfb10"
Expand Down
1 change: 1 addition & 0 deletions web/migrations/versions/54f71a7705a8_initial_tables2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Revises:
Create Date: 2023-01-03 18:01:03.770238
"""

import os
import sys

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Revises: 1094e771bd3f
Create Date: 2023-02-28 14:35:21.691915
"""

import os
import sys

Expand All @@ -16,7 +17,6 @@

import alembic_helpers


# revision identifiers, used by Alembic.
revision = "65acbe9b0646"
down_revision = "1094e771bd3f"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Revises: 54f71a7705a8
Create Date: 2023-02-28 14:29:28.456201
"""

import os
import sys

Expand All @@ -16,7 +17,6 @@

import alembic_helpers


# revision identifiers, used by Alembic.
revision = "7d80b9223a1e"
down_revision = "54f71a7705a8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Revises: 9aac3b5e1582
Create Date: 2022-08-12 09:09:47.674373
"""

import os
import sys

Expand All @@ -16,7 +17,6 @@

import alembic_helpers


# revision identifiers, used by Alembic.
revision = "8fe077ecfb10"
down_revision = "9aac3b5e1582"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Revises: 7d80b9223a1e
Create Date: 2021-05-06 17:44:17.835474
"""

import os
import sys

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
Revises: 65acbe9b0646
Create Date: 2022-08-12 15:43:01.721995
"""

import sqlalchemy as sa
from alembic import op


# revision identifiers, used by Alembic.
revision = "9d4ba8cf710a"
down_revision = "65acbe9b0646"
Expand Down
2 changes: 1 addition & 1 deletion web/misc/gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ def when_ready(server):
def worker_int(worker):
worker.log.info("worker received INT or QUIT signal")
## get traceback info
import threading
import sys
import threading
import traceback

id2name = {th.ident: th.name for th in threading.enumerate()}
Expand Down
Loading

0 comments on commit 31a70d4

Please sign in to comment.