From 6aca66d4b8c9adeb5cb08abe5e3c060298f8e6e4 Mon Sep 17 00:00:00 2001 From: Phil Gyford Date: Mon, 14 Feb 2022 11:33:36 +0000 Subject: [PATCH] Please the linter For #229 --- ditto/twitter/admin.py | 40 ++++++++++++++++--- ditto/twitter/ingest.py | 5 ++- ...057_alter_account_access_token_and_more.py | 32 +++++++++------ tests/twitter/test_ingest_v2.py | 4 +- 4 files changed, 58 insertions(+), 23 deletions(-) diff --git a/ditto/twitter/admin.py b/ditto/twitter/admin.py index abddfe63..e2dcdaf8 100644 --- a/ditto/twitter/admin.py +++ b/ditto/twitter/admin.py @@ -17,7 +17,15 @@ class AccountAdmin(admin.ModelAdmin): ) fieldsets = ( - (None, {"fields": ("user", "is_active",)}), + ( + None, + { + "fields": ( + "user", + "is_active", + ) + }, + ), ( "API", { @@ -29,7 +37,8 @@ class AccountAdmin(admin.ModelAdmin): ), "description": ( "Keys and secrets require creation of an app at " - 'developer.twitter.com/portal' + '' + "developer.twitter.com/portal" ), }, ), @@ -123,7 +132,13 @@ class MediaAdmin(admin.ModelAdmin): ), ( "Data", - {"classes": ("collapse",), "fields": ("time_created", "time_modified",)}, + { + "classes": ("collapse",), + "fields": ( + "time_created", + "time_modified", + ), + }, ), ) @@ -240,7 +255,12 @@ class TweetAdmin(DittoItemModelAdmin): "Data", { "classes": ("collapse",), - "fields": ("raw", "fetch_time", "time_created", "time_modified",), + "fields": ( + "raw", + "fetch_time", + "time_created", + "time_modified", + ), }, ), ) @@ -309,7 +329,17 @@ class UserAdmin(admin.ModelAdmin): ) }, ), - ("Data", {"fields": ("raw", "fetch_time", "time_created", "time_modified",)}), + ( + "Data", + { + "fields": ( + "raw", + "fetch_time", + "time_created", + "time_modified", + ) + }, + ), ) formfield_overrides = { diff --git a/ditto/twitter/ingest.py b/ditto/twitter/ingest.py index 663fc660..5ec22ecd 100644 --- a/ditto/twitter/ingest.py +++ b/ditto/twitter/ingest.py @@ -226,8 +226,9 @@ def _save_media(self, directory): media_obj.media_type != "video" and media_obj.has_file is False ): - # We don't save video files - only image files, and mp4s for # GIFs - and only want to do this if we don't already have a - # file. + # We don't save video files - only image files, and mp4s + # for # GIFs - and only want to do this if we don't already + # have a file. if ( media_obj.media_type == "animated_gif" diff --git a/ditto/twitter/migrations/0057_alter_account_access_token_and_more.py b/ditto/twitter/migrations/0057_alter_account_access_token_and_more.py index c4fd2ad2..7ab998fd 100644 --- a/ditto/twitter/migrations/0057_alter_account_access_token_and_more.py +++ b/ditto/twitter/migrations/0057_alter_account_access_token_and_more.py @@ -6,28 +6,34 @@ class Migration(migrations.Migration): dependencies = [ - ('twitter', '0056_add_count_index'), + ("twitter", "0056_add_count_index"), ] operations = [ migrations.AlterField( - model_name='account', - name='access_token', - field=models.CharField(blank=True, max_length=255, verbose_name='Access Token'), + model_name="account", + name="access_token", + field=models.CharField( + blank=True, max_length=255, verbose_name="Access Token" + ), ), migrations.AlterField( - model_name='account', - name='access_token_secret', - field=models.CharField(blank=True, max_length=255, verbose_name='Access Token Secret'), + model_name="account", + name="access_token_secret", + field=models.CharField( + blank=True, max_length=255, verbose_name="Access Token Secret" + ), ), migrations.AlterField( - model_name='account', - name='consumer_key', - field=models.CharField(blank=True, max_length=255, verbose_name='API Key'), + model_name="account", + name="consumer_key", + field=models.CharField(blank=True, max_length=255, verbose_name="API Key"), ), migrations.AlterField( - model_name='account', - name='consumer_secret', - field=models.CharField(blank=True, max_length=255, verbose_name='API Key Secret'), + model_name="account", + name="consumer_secret", + field=models.CharField( + blank=True, max_length=255, verbose_name="API Key Secret" + ), ), ] diff --git a/tests/twitter/test_ingest_v2.py b/tests/twitter/test_ingest_v2.py index 119fc304..ca4dabc5 100644 --- a/tests/twitter/test_ingest_v2.py +++ b/tests/twitter/test_ingest_v2.py @@ -1,11 +1,9 @@ import json import os -from unittest.mock import call, mock_open, patch from django.test import TestCase -from ditto.twitter import factories -from ditto.twitter.ingest import IngestError, Version2TweetIngester +from ditto.twitter.ingest import Version2TweetIngester from ditto.twitter.models import Tweet, User