Skip to content

Commit

Permalink
chore: Remove unused imports and variables (#6790)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamareebjamal committed Jan 26, 2020
1 parent b7ed60b commit 1559c4c
Show file tree
Hide file tree
Showing 35 changed files with 10 additions and 61 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion .hound.yml
@@ -1,3 +1,3 @@
python:
enabled: true
config_file: .flake8.ini
config_file: .flake8
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
@@ -1,8 +1,4 @@
repos:
- repo: https://github.com/timothycrosley/isort
rev: '4.3.21-2'
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: stable
hooks:
Expand Down
Empty file added app/__init__.py
Empty file.
1 change: 0 additions & 1 deletion app/api/admin_statistics_api/mails.py
Expand Up @@ -7,7 +7,6 @@

from app.api.bootstrap import api
from app.api.data_layers.NoModelLayer import NoModelLayer
from app.api.helpers.db import get_count
from app.api.helpers.utilities import dasherize
from app.models import db
from app.models.mail import Mail
Expand Down
1 change: 0 additions & 1 deletion app/api/admin_statistics_api/users.py
Expand Up @@ -7,7 +7,6 @@
from app.api.helpers.db import get_count
from app.api.helpers.utilities import dasherize
from app.models import db
from app.models.event import Event
from app.models.role import Role
from app.models.ticket_holder import TicketHolder
from app.models.user import User
Expand Down
1 change: 0 additions & 1 deletion app/api/attendees.py
Expand Up @@ -217,7 +217,6 @@ def before_update_object(self, obj, data, kwargs):
# raise ForbiddenException({'source': 'User'}, 'You are not authorized to access this.')

if 'ticket' in data:
user = safe_query(self, User, 'id', current_user.id, 'user_id')
ticket = (
db.session.query(Ticket)
.filter_by(id=int(data['ticket']), deleted_at=None)
Expand Down
8 changes: 0 additions & 8 deletions app/api/data_layers/EventCopyLayer.py
Expand Up @@ -50,23 +50,20 @@ def create_object(self, data, view_kwargs):

# Removes access_codes, order_tickets, ticket_tags for the new tickets created.
for ticket in tickets:
ticket_id = ticket.id
db.session.expunge(ticket) # expunge the object from session
make_transient(ticket)
ticket.event_id = event.id
delattr(ticket, 'id')
save_to_db(ticket)

for link in social_links:
link_id = link.id
db.session.expunge(link) # expunge the object from session
make_transient(link)
link.event_id = event.id
delattr(link, 'id')
save_to_db(link)

for sponsor in sponsors:
sponsor_id = sponsor.id
db.session.expunge(sponsor) # expunge the object from session
make_transient(sponsor)
sponsor.event_id = event.id
Expand All @@ -78,7 +75,6 @@ def create_object(self, data, view_kwargs):
save_to_db(sponsor)

for location in microlocations:
location_id = location.id
db.session.expunge(location) # expunge the object from session
make_transient(location)
location.event_id = event.id
Expand All @@ -87,31 +83,27 @@ def create_object(self, data, view_kwargs):

# No sessions are copied for new tracks
for track in tracks:
track_id = track.id
db.session.expunge(track) # expunge the object from session
make_transient(track)
track.event_id = event.id
delattr(track, 'id')
save_to_db(track)

for call in speaker_calls:
call_id = call.id
db.session.expunge(call) # expunge the object from session
make_transient(call)
call.event_id = event.id
delattr(call, 'id')
save_to_db(call)

for code in discount_codes:
code_id = code.id
db.session.expunge(code) # expunge the object from session
make_transient(code)
code.event_id = event.id
delattr(code, 'id')
save_to_db(code)

for form in custom_forms:
form_id = form.id
db.session.expunge(form) # expunge the object from session
make_transient(form)
form.event_id = event.id
Expand Down
1 change: 0 additions & 1 deletion app/api/event_copy.py
Expand Up @@ -2,7 +2,6 @@
from sqlalchemy.orm import make_transient

from app.api.helpers.db import safe_query, save_to_db
from app.api.helpers.files import create_save_resized_image
from app.api.helpers.permission_manager import has_access
from app.models import db
from app.models.custom_form import CustomForms
Expand Down
1 change: 0 additions & 1 deletion app/api/faqs.py
Expand Up @@ -4,7 +4,6 @@
from app.api.bootstrap import api
from app.api.helpers.db import safe_query
from app.api.helpers.permission_manager import has_access
from app.api.helpers.permissions import jwt_required
from app.api.helpers.query import event_query
from app.api.helpers.utilities import require_relationship
from app.api.schema.faqs import FaqSchema
Expand Down
1 change: 0 additions & 1 deletion app/api/feedbacks.py
Expand Up @@ -7,7 +7,6 @@
from app.api.helpers.exceptions import ForbiddenException, UnprocessableEntity
from app.api.helpers.feedback import delete_feedback
from app.api.helpers.permission_manager import has_access
from app.api.helpers.permissions import jwt_required
from app.api.helpers.query import event_query
from app.api.helpers.utilities import require_relationship
from app.api.schema.feedbacks import FeedbackSchema
Expand Down
3 changes: 1 addition & 2 deletions app/api/helpers/db.py
@@ -1,5 +1,4 @@
import logging
import traceback

from flask import request
from flask_rest_jsonapi.exceptions import ObjectNotFound
Expand All @@ -23,7 +22,7 @@ def save_to_db(item, msg="Saved to db", print_error=True):
logging.info('added to session')
db.session.commit()
return True
except Exception as e:
except Exception:
logging.exception('DB Exception!')
db.session.rollback()
return False
Expand Down
4 changes: 0 additions & 4 deletions app/api/helpers/jwt.py
@@ -1,11 +1,7 @@
import base64
import json

from flask import _app_ctx_stack as ctx_stack
from flask_jwt_extended.config import config
from flask_jwt_extended.exceptions import JWTExtendedException, UserLoadError
from flask_jwt_extended.view_decorators import _decode_jwt_from_request, _load_user
from flask_scrypt import check_password_hash
from jwt.exceptions import PyJWTError

from app.models.user import User
Expand Down
4 changes: 2 additions & 2 deletions app/api/helpers/order.py
Expand Up @@ -30,7 +30,7 @@ def delete_related_attendees_for_order(order):
db.session.delete(ticket_holder)
try:
db.session.commit()
except Exception as e:
except Exception:
logging.exception('DB Exception!')
db.session.rollback()

Expand Down Expand Up @@ -156,7 +156,7 @@ def create_onsite_attendees_for_order(data):
db.session.delete(ticket_holder)
try:
db.session.commit()
except Exception as e:
except Exception:
logging.exception('DB Exception!')
db.session.rollback()

Expand Down
1 change: 0 additions & 1 deletion app/api/helpers/permission_manager.py
@@ -1,4 +1,3 @@
from flask import current_app as app
from flask import request
from flask_jwt_extended import current_user, verify_jwt_in_request
from sqlalchemy.orm.exc import NoResultFound
Expand Down
3 changes: 1 addition & 2 deletions app/api/helpers/scheduled_jobs.py
Expand Up @@ -5,7 +5,7 @@
from flask import render_template
from flask_celeryext import RequestContextTask

from app.api.helpers.db import safe_query, save_to_db
from app.api.helpers.db import save_to_db
from app.api.helpers.files import create_save_pdf
from app.api.helpers.mail import (
send_email_after_event,
Expand All @@ -27,7 +27,6 @@
from app.models.order import Order
from app.models.session import Session
from app.models.speaker import Speaker
from app.models.ticket import Ticket
from app.models.ticket_fee import TicketFees, get_fee
from app.models.ticket_holder import TicketHolder
from app.settings import get_settings
Expand Down
1 change: 0 additions & 1 deletion app/api/helpers/tasks.py
@@ -1,6 +1,5 @@
import base64
import csv
import json
import logging
import os
import urllib.error
Expand Down
1 change: 0 additions & 1 deletion app/api/helpers/utilities.py
Expand Up @@ -3,7 +3,6 @@
import random
import re
import string
import sys

import bleach
import requests
Expand Down
2 changes: 1 addition & 1 deletion app/api/orders.py
Expand Up @@ -844,7 +844,7 @@ def omise_checkout(order_identifier):
f"""OmiseError: {repr(e)}. See https://www.omise.co/api-errors"""
)
return jsonify(status=False, error="Omise Failure Message: {}".format(str(e)))
except Exception as e:
except Exception:
logging.exception('Error while charging omise')
if charge.failure_code is not None:
logging.warning(
Expand Down
1 change: 0 additions & 1 deletion app/api/panel_permissions.py
Expand Up @@ -2,7 +2,6 @@

from app.api.bootstrap import api
from app.api.helpers.db import safe_query
from app.api.helpers.utilities import require_relationship
from app.api.schema.panel_permissions import PanelPermissionSchema
from app.models import db
from app.models.custom_system_role import CustomSysRole
Expand Down
2 changes: 1 addition & 1 deletion app/api/routes.py
Expand Up @@ -83,7 +83,7 @@
)
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
from app.api.events import EventDetail, EventList, EventRelationship
from app.api.events_role_permission import (
EventsRolePermissionDetail,
EventsRolePermissionList,
Expand Down
2 changes: 0 additions & 2 deletions app/api/schema/events.py
@@ -1,5 +1,3 @@
from datetime import datetime

import pytz
from flask_rest_jsonapi.exceptions import ObjectNotFound
from marshmallow import validate, validates_schema
Expand Down
1 change: 0 additions & 1 deletion app/api/session_types.py
Expand Up @@ -4,7 +4,6 @@
from app.api.helpers.db import safe_query
from app.api.helpers.exceptions import ForbiddenException
from app.api.helpers.permission_manager import has_access
from app.api.helpers.permissions import jwt_required
from app.api.helpers.query import event_query
from app.api.helpers.utilities import require_relationship
from app.api.schema.session_types import SessionTypeSchema
Expand Down
1 change: 0 additions & 1 deletion app/api/sessions.py
Expand Up @@ -67,7 +67,6 @@ def after_create_object(self, session, data, view_kwargs):
event_name = session.event.name
owner = session.event.get_owner()
owner_email = owner.email
frontend_url = get_settings()['frontend_url']
event = session.event
link = make_frontend_url(
"/events/{}/sessions/{}".format(event.identifier, session.id)
Expand Down
4 changes: 1 addition & 3 deletions app/api/settings.py
@@ -1,6 +1,4 @@
from flask import Blueprint
from flask import current_app as app
from flask import jsonify, make_response, request
from flask import Blueprint, jsonify, make_response, request
from flask_jwt_extended import current_user, verify_jwt_in_request
from flask_rest_jsonapi import ResourceDetail

Expand Down
1 change: 0 additions & 1 deletion app/api/stripe_authorization.py
Expand Up @@ -2,7 +2,6 @@
from flask_rest_jsonapi import ResourceDetail, ResourceList
from sqlalchemy.orm.exc import NoResultFound

from app.api.bootstrap import api
from app.api.helpers.db import get_count, safe_query, save_to_db
from app.api.helpers.exceptions import (
ConflictException,
Expand Down
2 changes: 1 addition & 1 deletion app/api/users.py
Expand Up @@ -12,7 +12,7 @@
ForbiddenException,
UnprocessableEntity,
)
from app.api.helpers.files import create_save_image_sizes, make_frontend_url
from app.api.helpers.files import make_frontend_url
from app.api.helpers.mail import (
send_email_change_user_email,
send_email_confirmation,
Expand Down
1 change: 0 additions & 1 deletion app/models/event_topic.py
@@ -1,4 +1,3 @@
import urllib.parse
import uuid

from app.api.helpers.db import get_count
Expand Down
1 change: 0 additions & 1 deletion tests/all/integration/api/helpers/test_files.py
@@ -1,4 +1,3 @@
import json
import os
import unittest
from io import BytesIO
Expand Down
2 changes: 1 addition & 1 deletion tests/all/integration/api/helpers/test_pentabarfxml.py
@@ -1,6 +1,6 @@
import unittest
from datetime import datetime
from xml.etree.ElementTree import fromstring, tostring
from xml.etree.ElementTree import fromstring

from app.api.helpers.db import save_to_db
from app.api.helpers.pentabarfxml import PentabarfExporter
Expand Down
Expand Up @@ -11,7 +11,6 @@
)
from app.factories.event import EventFactoryBasic
from app.factories.user import UserFactory
from app.models import db
from app.models.users_events_role import UsersEventsRoles
from tests.all.integration.setup_database import Setup
from tests.all.integration.utils import OpenEventTestCase
Expand Down
4 changes: 0 additions & 4 deletions tests/all/integration/api/validation/test_sessions.py
@@ -1,9 +1,5 @@
import unittest
from datetime import datetime

from pytz import timezone

from app.api.helpers.exceptions import UnprocessableEntity
from app.api.schema.sessions import SessionSchema
from app.factories.session import SessionFactory
from tests.all.integration.utils import OpenEventTestCase
Expand Down
4 changes: 0 additions & 4 deletions tests/all/integration/api/validation/test_speakers_call.py
@@ -1,9 +1,5 @@
import unittest
from datetime import datetime

from pytz import timezone

from app.api.helpers.exceptions import UnprocessableEntity
from app.api.schema.speakers_calls import SpeakersCallSchema
from app.factories.speakers_call import SpeakersCallFactory
from tests.all.integration.utils import OpenEventTestCase
Expand Down
4 changes: 0 additions & 4 deletions tests/all/integration/api/validation/test_tickets.py
@@ -1,9 +1,5 @@
import unittest
from datetime import datetime

from pytz import timezone

from app.api.helpers.exceptions import UnprocessableEntity
from app.api.schema.tickets import TicketSchema
from app.factories.ticket import TicketFactory
from tests.all.integration.utils import OpenEventTestCase
Expand Down
1 change: 0 additions & 1 deletion tests/all/unit/api/helpers/test_storage.py
Expand Up @@ -2,7 +2,6 @@
import os
import unittest
from tempfile import TemporaryDirectory
from unittest.mock import patch

from app.api.helpers.storage import UploadedFile, create_url, generate_hash

Expand Down

0 comments on commit 1559c4c

Please sign in to comment.