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
ref: Add black, isort and pre-commit hook #6787
Conversation
from app.factories.attendee import AttendeeFactoryBase, AttendeeFactory | ||
from app.api.attendees import get_sold_and_reserved_tickets_count | ||
from app.api.helpers.db import save_to_db | ||
from app.api.helpers.order import delete_related_attendees_for_order, set_expiry_for_order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
) | ||
from app.api.event_topics import EventTopicDetail, EventTopicList, EventTopicRelationship | ||
from app.api.event_types import EventTypeDetail, EventTypeList, EventTypeRelationship | ||
from app.api.events import EventCopyResource, EventDetail, EventList, EventRelationship |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'app.api.events.EventCopyResource' imported but unused
EventSubTopicRelationshipOptional, | ||
EventSubTopicRelationshipRequired, | ||
) | ||
from app.api.event_topics import EventTopicDetail, EventTopicList, EventTopicRelationship |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
) | ||
from app.api.helpers.ICalExporter import ICalExporter | ||
from app.api.helpers.mail import check_smtp_config, send_export_mail, send_import_mail | ||
from app.api.helpers.notification import send_notif_after_export, send_notif_after_import |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
from flask_jwt_extended import current_user | ||
from sqlalchemy.orm.exc import NoResultFound | ||
|
||
from app.api.helpers.errors import ForbiddenError, NotFoundError, UnprocessableEntityError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
from app.api.auth import return_file | ||
from app.api.helpers.db import safe_query, get_count | ||
from app.api.helpers.db import get_count, safe_query | ||
from app.api.helpers.errors import ForbiddenError, NotFoundError, UnprocessableEntityError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black would make changes.
Codecov Report
@@ Coverage Diff @@
## development #6787 +/- ##
===============================================
- Coverage 65.38% 65.31% -0.07%
===============================================
Files 302 302
Lines 15348 15319 -29
===============================================
- Hits 10035 10006 -29
Misses 5313 5313
Continue to review full report at Codecov.
|
@@ -4057,7 +4223,9 @@ def order_statistics_event_get(transaction): | |||
db.session.commit() | |||
|
|||
|
|||
@hooks.before("Order Statistics > Order Statistics Details By Ticket > Show Order Statistics By Ticket") | |||
@hooks.before( | |||
"Order Statistics > Order Statistics Details By Ticket > Show Order Statistics By Ticket" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (93 > 90 characters)
@hooks.before("Order Statistics > Order Statistics Details By Event > Show Order Statistics By Event") | ||
|
||
@hooks.before( | ||
"Order Statistics > Order Statistics Details By Event > Show Order Statistics By Event" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (91 > 90 characters)
@@ -3992,7 +4153,8 @@ def event_sessions_export_pdf_get(transaction): | |||
|
|||
|
|||
@hooks.before( | |||
"Event Export > Start Speakers Export as PDF > Start a Task to Export Speakers of an Event as PDF") | |||
"Event Export > Start Speakers Export as PDF > Start a Task to Export Speakers of an Event as PDF" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (102 > 90 characters)
@@ -3979,7 +4139,8 @@ def event_speakers_export_csv_get(transaction): | |||
|
|||
|
|||
@hooks.before( | |||
"Event Export > Start Sessions Export as PDF > Start a Task to Export Sessions of an Event as PDF") | |||
"Event Export > Start Sessions Export as PDF > Start a Task to Export Sessions of an Event as PDF" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (102 > 90 characters)
@@ -3966,7 +4125,8 @@ def event_sessions_export_csv_get(transaction): | |||
|
|||
|
|||
@hooks.before( | |||
"Event Export > Start Speakers Export as CSV > Start a Task to Export Speakers of an Event as CSV") | |||
"Event Export > Start Speakers Export as CSV > Start a Task to Export Speakers of an Event as CSV" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (102 > 90 characters)
@@ -3875,7 +4027,8 @@ def event_export_ical_get(transaction): | |||
|
|||
|
|||
@hooks.before( | |||
"Event Export > Start Event Export as xCalendar > Start a Task to Export an Event as xCalendar") | |||
"Event Export > Start Event Export as xCalendar > Start a Task to Export an Event as xCalendar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (99 > 90 characters)
@@ -3862,7 +4013,8 @@ def event_export_post(transaction): | |||
|
|||
|
|||
@hooks.before( | |||
"Event Export > Start Event Export as iCal file > Start a Task to Export an Event as iCal event") | |||
"Event Export > Start Event Export as iCal file > Start a Task to Export an Event as iCal event" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (100 > 90 characters)
@@ -3834,7 +3982,9 @@ def stripe_authorization_delete(transaction): | |||
db.session.commit() | |||
|
|||
|
|||
@hooks.before("Stripe Authorization > Stripe Authorization for an Event > Get Stripe Authorization Details of an Event") | |||
@hooks.before( | |||
"Stripe Authorization > Stripe Authorization for an Event > Get Stripe Authorization Details of an Event" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (109 > 90 characters)
@@ -3648,7 +3777,9 @@ def custom_placeholder_sub_topic_get_detail(transaction): | |||
|
|||
|
|||
# ------------------------- Custom Placeholders ------------------------- | |||
@hooks.before("Custom Placeholders > Custom Placeholders Collection > List All Event Custom Placeholders") | |||
@hooks.before( | |||
"Custom Placeholders > Custom Placeholders Collection > List All Event Custom Placeholders" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (95 > 90 characters)
@@ -3631,7 +3759,8 @@ def event_event_sub_topic_get_detail(transaction): | |||
|
|||
|
|||
@hooks.before( | |||
"Event Sub Topics > Event Sub Topic of Custom Placeholder > Event Sub Topic Details of Custom Placeholder") | |||
"Event Sub Topics > Event Sub Topic of Custom Placeholder > Event Sub Topic Details of Custom Placeholder" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (110 > 90 characters)
Here is an overview of what got changed by this pull request: Issues
======
+ Solved 47
- Added 12
Clones added
============
- app/api/admin_statistics_api/sessions.py 1
- app/api/admin_statistics_api/mails.py 1
- app/api/speakers.py 1
- app/api/order_statistics/events.py 5
- app/api/attendees.py 3
- app/api/tax.py 1
- app/api/sessions.py 1
- app/api/access_codes.py 1
- app/api/order_statistics/tickets.py 6
- app/api/admin_statistics_api/users.py 1
- app/api/tickets.py 1
- app/api/orders.py 2
- app/models/discount_code.py 1
- app/api/admin_sales/events.py 1
- app/models/access_code.py 1
- app/api/admin_sales/organizer.py 1
Clones removed
==============
+ app/models/event_sub_topic.py -1
+ app/models/event_type.py -1
+ tests/all/integration/api/helpers/test_systemnotifications.py -1
See the complete overview on Codacy |
@@ -613,21 +840,34 @@ def omise_checkout(order_identifier): | |||
try: | |||
charge = OmisePaymentsManager.charge_payment(order_identifier, token) | |||
except omise.errors.BaseError as e: | |||
logging.exception(f"""OmiseError: {repr(e)}. See https://www.omise.co/api-errors""") | |||
logging.exception( | |||
f"""OmiseError: {repr(e)}. See https://www.omise.co/api-errors""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: invalid syntax
) | ||
max = ( | ||
db.session.query(func.sum(Ticket.quantity.label('sum'))) | ||
.filter(Ticket.event_id == obj_id, Ticket.deleted_at == None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: comparison to None should be 'if cond is None:'
'DiscountCode', secondary=discount_codes_tickets, backref="tickets" | ||
) | ||
|
||
def __init__( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: as argument
TicketHolder.created_at + datetime.timedelta(minutes=order_expiry_time) | ||
< datetime.datetime.utcnow()).delete(synchronize_session=False) | ||
TicketHolder.query.filter( | ||
TicketHolder.order_id == None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: comparison to None should be 'if cond is None:'
speakers = Speaker.query.filter( | ||
Speaker.photo_url.isnot(None), | ||
or_( | ||
Speaker.icon_image_url == None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: comparison to None should be 'if cond is None:'
sys.path.insert(1, path.abspath(path.join(__file__, "../.."))) | ||
|
||
from flask_migrate import Migrate | ||
from flask import Flask | ||
from app.models import db | ||
from app.models.user import OWNER | ||
from app.models.user_token_blacklist import UserTokenBlackListTime # noqa Workaround for registering unimported model | ||
from app.models.user_token_blacklist import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -386,8 +388,9 @@ def import_event_json(task_handle, zip_path, creator_id): | |||
except ValueError: | |||
db.session.delete(new_event) | |||
db.session.commit() | |||
raise make_error(item[0], er=ServerError(source='Zip Upload', | |||
detail='Invalid json')) | |||
raise make_error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
events = Event.query.filter( | ||
Event.original_image_url.isnot(None), | ||
or_( | ||
Event.thumbnail_image_url == None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: comparison to None should be 'if cond is None:'
) | ||
from app.api.event_topics import EventTopicDetail, EventTopicList, EventTopicRelationship | ||
from app.api.event_types import EventTypeDetail, EventTypeList, EventTypeRelationship | ||
from app.api.events import EventCopyResource, EventDetail, EventList, EventRelationship |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app.logger.warning(f'Using random secret "{ random_secret }" for development server. ' | ||
'This is NOT recommended. Set proper SECRET_KEY in .env or environment variables') | ||
app.logger.warning( | ||
f'Using random secret "{ random_secret }" for development server. ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: invalid syntax
attendee_list = [] | ||
for ticket in tickets: | ||
for ticket_amount in range(ticket['quantity']): | ||
attendee = TicketHolder(**result[0], event_id=int(data['event_id']), ticket_id=int(ticket['id'])) | ||
attendee = TicketHolder( | ||
**result[0], event_id=int(data['event_id']), ticket_id=int(ticket['id']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: invalid syntax
) | ||
from app.api.event_topics import EventTopicDetail, EventTopicList, EventTopicRelationship | ||
from app.api.event_types import EventTypeDetail, EventTypeList, EventTypeRelationship | ||
from app.api.events import EventCopyResource, EventDetail, EventList, EventRelationship |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #6766