Skip to content
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

cleanup unused imports #699

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion mygpo/administration/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from django_db_geventpool.utils import close_connection

from mygpo.podcasts.models import Podcast
from mygpo.celery import celery
from mygpo.maintenance.merge import PodcastMerger

from celery.utils.log import get_task_logger
Expand Down
4 changes: 2 additions & 2 deletions mygpo/administration/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def test_merge(self):
subscribe(p1.pk, user.pk, device1.uid)
subscribe(p2.pk, user.pk, device2.uid)

action1 = EpisodeHistoryEntry.create_entry(user, e1, EpisodeHistoryEntry.PLAY)
action3 = EpisodeHistoryEntry.create_entry(user, e3, EpisodeHistoryEntry.PLAY)
EpisodeHistoryEntry.create_entry(user, e1, EpisodeHistoryEntry.PLAY)
EpisodeHistoryEntry.create_entry(user, e3, EpisodeHistoryEntry.PLAY)

# we need that for later
e3_id = e3.pk
Expand Down
6 changes: 2 additions & 4 deletions mygpo/administration/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
import socket
from itertools import count, chain
from collections import Counter
from itertools import count
from datetime import datetime

import redis
Expand All @@ -14,7 +13,6 @@
from django.core.cache import cache
from django.http import HttpResponseRedirect
from django.template.loader import render_to_string
from django.template import RequestContext
from django.utils.translation import gettext as _
from django.contrib.sites.requests import RequestSite
from django.views.generic import TemplateView
Expand All @@ -25,7 +23,7 @@
from mygpo.podcasts.models import Podcast, Episode
from mygpo.administration.auth import require_staff
from mygpo.administration.group import PodcastGrouper
from mygpo.maintenance.merge import PodcastMerger, IncorrectMergeException
from mygpo.maintenance.merge import IncorrectMergeException
from mygpo.administration.clients import UserAgentStats, ClientStats
from mygpo.users.views.registration import send_activation_email
from mygpo.administration.tasks import merge_podcasts
Expand Down
6 changes: 1 addition & 5 deletions mygpo/api/advanced/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from functools import partial

from collections import defaultdict
from datetime import datetime
from importlib import import_module

Expand All @@ -9,7 +6,6 @@
from django.http import (
HttpResponse,
HttpResponseBadRequest,
Http404,
HttpResponseNotFound,
)
from django.core.exceptions import ValidationError
Expand Down Expand Up @@ -307,7 +303,7 @@ def device(request, username, device_uid, version=None):

try:
data = parse_request_body(request)
except (UnicodeDecodeError, ValueError) as e:
except (UnicodeDecodeError, ValueError):
msg = ("Could not decode device update POST data for " + "user %s: %s") % (
username,
request.body.decode("ascii", errors="replace"),
Expand Down
2 changes: 1 addition & 1 deletion mygpo/api/advanced/episode.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from mygpo.api import APIView, RequestException
from mygpo.api.httpresponse import JsonResponse
from mygpo.api.exceptions import ParameterMissing
from mygpo.chapters.models import Chapter
from mygpo.chapters.models import Chapter, Episode, Podcast
from mygpo.utils import parse_time, normalize_feed_url, get_timestamp


Expand Down
4 changes: 1 addition & 3 deletions mygpo/api/advanced/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
from functools import partial
from datetime import datetime

from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseForbidden
from django.http import HttpResponse, HttpResponseBadRequest
from django.views.decorators.csrf import csrf_exempt
from django.urls import reverse
from django.contrib.sites.requests import RequestSite
from django.contrib.auth import get_user_model
from django.utils.text import slugify
from django.views.decorators.cache import never_cache
from django.http import Http404
from django.shortcuts import get_object_or_404

from mygpo.podcasts.models import Podcast
from mygpo.utils import get_timestamp
from mygpo.api.advanced.directory import podcast_data
from mygpo.api.httpresponse import JsonResponse
from mygpo.podcastlists.models import PodcastList
Expand Down
2 changes: 0 additions & 2 deletions mygpo/api/advanced/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

from django.shortcuts import get_object_or_404

from mygpo.api import APIView, RequestException
Expand Down
3 changes: 0 additions & 3 deletions mygpo/api/advanced/updates.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from itertools import chain
from datetime import datetime

from django.http import HttpResponseBadRequest, HttpResponseNotFound
Expand All @@ -16,7 +15,6 @@
from mygpo.subscriptions import get_subscription_history, subscription_diff
from mygpo.users.models import Client
from mygpo.episodestates.models import EpisodeState
from mygpo.users.subscriptions import subscription_changes, podcasts_for_states
from mygpo.api.basic_auth import require_valid_user, check_username
from mygpo.decorators import cors_origin

Expand All @@ -42,7 +40,6 @@ class DeviceUpdates(View):
def get(self, request, username, device_uid):

now = datetime.utcnow()
now_ = get_timestamp(now)

user = request.user

Expand Down
1 change: 0 additions & 1 deletion mygpo/api/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from mygpo.users.models import Client
from mygpo.subscriptions.tasks import subscribe, unsubscribe
from mygpo.subscriptions import get_subscription_history, subscription_diff
from mygpo.api.basic_auth import require_valid_user, check_username

import logging

Expand Down
1 change: 0 additions & 1 deletion mygpo/api/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from django_db_geventpool.utils import close_connection

from mygpo.celery import celery
from mygpo.api.advanced import update_episodes

logger = get_task_logger(__name__)
Expand Down
1 change: 0 additions & 1 deletion mygpo/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from django.test.utils import override_settings

from openapi_spec_validator import validate_spec_url
from jsonschema import ValidationError

from mygpo.podcasts.models import Podcast, Episode
from mygpo.api.advanced import episodes
Expand Down
2 changes: 0 additions & 2 deletions mygpo/celery.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os

from django.conf import settings

from celery import Celery

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mygpo.settings")
Expand Down
2 changes: 1 addition & 1 deletion mygpo/chapters/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.conf import settings

from mygpo.core.models import UpdateInfoModel
from mygpo.podcasts.models import Episode
from mygpo.podcasts.models import Episode, Podcast


class Chapter(UpdateInfoModel):
Expand Down
8 changes: 1 addition & 7 deletions mygpo/data/feeddownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
# -*- coding: utf-8 -*-

import os.path
import urllib.request
import urllib.error
from urllib.parse import urljoin
import hashlib
from datetime import datetime, timedelta
from itertools import chain, islice
import requests
Expand Down Expand Up @@ -65,7 +62,7 @@ def update_podcasts(queue):
except NoPodcastCreated as npc:
logger.info("No podcast created: %s", npc)

except NoEpisodesException as nee:
except NoEpisodesException:
logger.info(f"No episodes found when parsing {podcast_url}")
continue

Expand Down Expand Up @@ -339,9 +336,6 @@ def __init__(self, podcast, update_result):
self.max_episode_order = None

def update_episodes(self, parsed_episodes):

pid = self.podcast.get_id()

episodes_to_update = list(islice(parsed_episodes, 0, MAX_EPISODES_UPDATE))
logger.info(
"Parsed %d (%d) episodes", len(parsed_episodes), len(episodes_to_update)
Expand Down
2 changes: 1 addition & 1 deletion mygpo/data/flickr.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_photo_sizes(photo_id):

try:
resp_obj = resp.json()
except json.JSONDecodeError as jde:
except json.JSONDecodeError:
return []

try:
Expand Down
2 changes: 0 additions & 2 deletions mygpo/data/management/commands/feed-downloader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from itertools import islice
import traceback
from optparse import make_option

from mygpo.maintenance.management.podcastcmd import PodcastCommand
from mygpo.data.feeddownloader import update_podcasts
Expand Down
1 change: 0 additions & 1 deletion mygpo/data/management/commands/tag-downloader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import time
import urllib.request, urllib.error, urllib.parse
from optparse import make_option

from mygpo.data import delicious
from mygpo.maintenance.management.podcastcmd import PodcastCommand
Expand Down
13 changes: 6 additions & 7 deletions mygpo/data/podcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ def calc_similar_podcasts(podcast, num=20, user_sample=100):

# get other podcasts that the user sample subscribes to
podcasts = Counter()
for user_id in user_ids:
subscriptions = (
Podcast.objects.filter(subscription__user__id__in=user_ids)
.distinct("pk")
.exclude(pk=podcast.pk)
)
podcasts.update(Counter(subscriptions))
subscriptions = (
Podcast.objects.filter(subscription__user__id__in=user_ids)
.distinct("pk")
.exclude(pk=podcast.pk)
)
podcasts.update(Counter(subscriptions))
logger.info(
"Found {num_podcasts}, returning top {num_results}".format(
num_podcasts=len(podcasts), num_results=num
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from datetime import datetime

from django.core.management.base import BaseCommand
from django.utils.text import slugify

Expand All @@ -20,7 +18,6 @@ def handle(self, *args, **options):
)
return

start_time = datetime.utcnow()
cat_name = args[0]
spellings = args[1:]

Expand Down
2 changes: 0 additions & 2 deletions mygpo/directory/management/commands/update-toplist.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from optparse import make_option

from django.core.management.base import BaseCommand

from mygpo.podcasts.models import Podcast
Expand Down
2 changes: 1 addition & 1 deletion mygpo/directory/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def search_podcasts(q):
if not podcast or not podcast.title:
try:
updater.update_podcast()
except NoPodcastCreated as npc:
except NoPodcastCreated:
return []

try:
Expand Down
1 change: 0 additions & 1 deletion mygpo/directory/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from mygpo.podcasts.models import Podcast
from mygpo.subscriptions.models import Subscription
from mygpo.celery import celery


@shared_task(max_retries=5)
Expand Down
2 changes: 0 additions & 2 deletions mygpo/directory/tests.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import unittest
import doctest
import uuid
from datetime import datetime

from django.test import TestCase

from mygpo.podcasts.models import Podcast
from mygpo.directory.views import ToplistView
Expand Down
4 changes: 1 addition & 3 deletions mygpo/directory/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.utils.translation import gettext as _
from django.contrib.auth import get_user_model

from mygpo.podcasts.models import Podcast, Episode
from mygpo.directory.search import search_podcasts
from mygpo.web.utils import (
process_lang_params,
get_language_names,
get_page_list,
get_podcast_link_target,
sanitize_language_codes,
)
from mygpo.directory.tags import Topics
Expand Down Expand Up @@ -335,7 +333,7 @@ def get(self, request, task_id):

except (UpdatePodcastException, NoEpisodesException) as ex:
messages.error(request, str(ex))
podcast = None
podcasts = []

return self.render_to_response({"ready": True, "podcasts": podcasts})

Expand Down
3 changes: 1 addition & 2 deletions mygpo/episodestates/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django_db_geventpool.utils import close_connection
from celery import shared_task

from mygpo.celery import celery
from mygpo.history.models import EpisodeHistoryEntry
from mygpo.episodestates.models import EpisodeState

Expand Down Expand Up @@ -31,7 +30,7 @@ def update_episode_state(historyentry_pk):
)
)

state = EpisodeState.objects.update_or_create(
EpisodeState.objects.update_or_create(
user=user,
episode=episode,
defaults={"action": historyentry.action, "timestamp": historyentry.timestamp},
Expand Down
2 changes: 1 addition & 1 deletion mygpo/favorites/migrations/0002_unique.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-


from django.db import models, migrations
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion mygpo/history/migrations/0002_pluralname.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-


from django.db import models, migrations
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion mygpo/history/migrations/0006_episodehistory_index.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-


from django.db import models, migrations
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion mygpo/history/migrations/0007_episodehistory_index.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-


from django.db import models, migrations
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion mygpo/history/migrations/0008_episodehistory_index.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-


from django.db import models, migrations
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion mygpo/history/migrations/0010_episode_history_index.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from django.db import models, migrations
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
1 change: 0 additions & 1 deletion mygpo/history/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from collections import Counter
from datetime import datetime

from django.db import models
Expand Down
Loading