Skip to content

Commit 87b9959

Browse files
authored
Lint: one step forward through linting our code (#10129)
* Lint: trailing lines and whitespaces * Lint: remove outdated encoding pragma * Lint: outdated symlink * Lint: remove unused imports * Lint: noqa places where autoflake gets confused * Lint: permalinks * Lint: trailing whitespaces * Lint: end-of-file fixes * Lint: typo * Lint: darker over modified files * Lint: add some missing docstrings * Lint: keep this file as is, since it's used in tests * pre-commit: update common to update changes
1 parent e39dbd9 commit 87b9959

File tree

168 files changed

+61
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+61
-294
lines changed

.github/config.yml

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ todo:
66
blobLines: 7
77
caseSensitive: true
88
keyword: "TODO"
9-

LICENSE

-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
2020
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2121
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2222
OTHER DEALINGS IN THE SOFTWARE.
23-

common

docs/dev/design/new-sphinx-guides.rst

+1-1

docs/dev/design/organizations.rst

+1-1

docs/dev/design/sphinx-jquery.rst

+1-1

docs/user/.tx/config

-1
Original file line numberDiff line numberDiff line change
@@ -426,4 +426,3 @@ file_filter = locale/<lang>/LC_MESSAGES/settings.po
426426
source_file = _build/locale/settings.pot
427427
source_lang = en
428428
type = PO
429-

media/robots.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ Disallow: /builds/
55
Disallow: /sustainability/click/
66

77
# This was hitting our site and causing a lot of issues
8-
User-agent: AhrefsBot
8+
User-agent: AhrefsBot
99
Disallow: /

prospector-more.yml

-1
This file was deleted.

readthedocs/api/v3/renderers.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1+
"""Renders with some extra capabilities we require for our own purposes."""
2+
13
import json
24

3-
from rest_framework.compat import (
4-
INDENT_SEPARATORS,
5-
LONG_SEPARATORS,
6-
SHORT_SEPARATORS,
7-
)
5+
from rest_framework.compat import INDENT_SEPARATORS, LONG_SEPARATORS, SHORT_SEPARATORS
86
from rest_framework.renderers import JSONRenderer
97

108

@@ -25,7 +23,7 @@ def render(self, data, accepted_media_type=None, renderer_context=None):
2523
- sort_keys=True on json.dumps
2624
- use str instead of six.text_types
2725
28-
https://github.com/encode/django-rest-framework/blob/master/rest_framework/renderers.py#L89
26+
https://github.com/encode/django-rest-framework/blob/b7523f4/rest_framework/renderers.py#L84
2927
"""
3028
if data is None:
3129
return bytes()

readthedocs/builds/apps.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import structlog
1+
"""Django configuration for readthedocs.builds application."""
22

3+
import structlog
34
from django.apps import AppConfig
45
from django.utils.translation import gettext_lazy as _
56

@@ -12,4 +13,4 @@ class Config(AppConfig):
1213
verbose_name = _("Builds")
1314

1415
def ready(self):
15-
import readthedocs.builds.tasks
16+
import readthedocs.builds.tasks # noqa

readthedocs/builds/migrations/0001_initial.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import taggit.managers
32
from django.db import migrations, models
43

readthedocs/builds/migrations/0002_build_command_initial.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from django.db import migrations, models
32

43
import readthedocs.builds.models

readthedocs/builds/migrations/0003_add-cold-storage.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.9.12 on 2017-10-09 20:14
32
from django.db import migrations, models
43

readthedocs/builds/migrations/0004_add-apiversion-proxy-model.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.9.12 on 2017-10-27 00:17
32
from django.db import migrations
43

readthedocs/builds/migrations/0005_remove-version-alias.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.9.13 on 2018-10-17 04:20
32
from django.db import migrations, models
43

readthedocs/builds/migrations/0006_add_config_field.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.16 on 2018-11-02 13:24
32
import jsonfield.fields
43
from django.db import migrations

readthedocs/builds/migrations/0007_add-automation-rules.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.20 on 2019-04-25 23:04
3-
from __future__ import unicode_literals
4-
5-
from django.db import migrations, models
62
import django.db.models.deletion
73
import django_extensions.db.fields
4+
from django.db import migrations, models
85

96

107
class Migration(migrations.Migration):

readthedocs/builds/migrations/0008_remove-version-tags.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.20 on 2019-06-28 16:29
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations
63

74

readthedocs/builds/migrations/0009_added_external_version_type.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.21 on 2019-07-04 13:10
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63

74

readthedocs/builds/migrations/0010_add-description-field-to-automation-rule.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.22 on 2019-07-25 17:24
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63

74

readthedocs/builds/migrations/0011_version-media-availability.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.23 on 2019-10-07 23:32
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63

74

readthedocs/builds/migrations/0012_add-predefined-match-arg-field.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.25 on 2019-11-05 23:54
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63

74

readthedocs/builds/migrations/0013_version_documentation_type.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.27 on 2020-01-14 17:37
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations, models
63

74

readthedocs/builds/migrations/0014_migrate-doctype-from-project-to-version.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.27 on 2020-01-14 17:40
32

43
from django.db import migrations

readthedocs/builds/migrations/0031_add_version_fields_to_build.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Generated by Django 2.2.16 on 2020-11-18 21:52
22

33
from django.db import migrations, models
4-
import django.db.models.deletion
54

65

76
class Migration(migrations.Migration):

readthedocs/builds/migrations/0040_remove_old_jsonfields.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generated by Django 3.2.11 on 2022-01-31 12:12
22

3-
from django.db import migrations, models
3+
from django.db import migrations
44

55

66
class Migration(migrations.Migration):

readthedocs/builds/tests/test_celery_task_router.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import django_dynamic_fixture as fixture
2-
from django.conf import settings
32
from django.test import TestCase
4-
from django.test.utils import override_settings
53

64
from readthedocs.builds.constants import EXTERNAL
75
from readthedocs.builds.models import Build, Version

readthedocs/builds/version_slug.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21

32
"""
43
Contains logic for handling version slugs.

readthedocs/config/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21

32
"""Logic to parse and validate ``readthedocs.yaml`` file."""
43
from .config import * # noqa

readthedocs/config/find.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21

32
"""Helper functions to search files."""
43

readthedocs/config/parser.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21

32
"""YAML parser for the RTD configuration file."""
43

readthedocs/config/tests/test_find.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import os
32

43
from readthedocs.config.find import find_one

readthedocs/config/tests/test_parser.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from io import StringIO
32

43
from pytest import raises

readthedocs/config/tests/test_utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from .utils import apply_fs
32

43

readthedocs/config/tests/test_validation.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import os
21

3-
from unittest.mock import patch
42
from pytest import raises
53

64
from readthedocs.config.validation import (

readthedocs/config/tests/test_yaml_loader.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from readthedocs.doc_builder.backends.mkdocs import (
2+
ProxyPythonName,
23
yaml_dump_safely,
34
yaml_load_safely,
4-
ProxyPythonName
55
)
66

77
content = '''
@@ -35,4 +35,3 @@ def test_yaml_load_safely():
3535
def test_yaml_dump_safely():
3636
data = yaml_load_safely(content)
3737
assert yaml_load_safely(yaml_dump_safely(data)) == data
38-

readthedocs/config/tests/utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21

32
def apply_fs(tmpdir, contents):
43
"""

readthedocs/core/apps.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""App configurations for core app."""
22

33
import structlog
4-
54
from django.apps import AppConfig
65

76
log = structlog.get_logger(__name__)
@@ -12,12 +11,11 @@ class CoreAppConfig(AppConfig):
1211
verbose_name = 'Core'
1312

1413
def ready(self):
15-
import readthedocs.core.signals # noqa
16-
1714
# Import `readthedocs.core.logs` to set up structlog
1815
import readthedocs.core.logs # noqa
16+
import readthedocs.core.signals # noqa
1917

2018
try:
21-
import readthedocsext.monitoring.metrics.tasks
19+
import readthedocsext.monitoring.metrics.tasks # noqa
2220
except (ModuleNotFoundError, ImportError):
2321
log.info('Metrics tasks could not be imported.')

readthedocs/core/backends.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21

32
"""Email backends for core app."""
43

readthedocs/core/context_processors.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21

32
"""Template context processors for core app."""
43

readthedocs/core/fields.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21

32
"""Shared model fields and defaults."""
43

readthedocs/core/migrations/0001_initial.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from django.conf import settings
32
from django.db import migrations, models
43

readthedocs/core/migrations/0002_make_userprofile_user_a_onetoonefield.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from django.conf import settings
32
from django.db import migrations, models
43

readthedocs/core/migrations/0003_add_banned_status.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from django.db import migrations, models
32

43

readthedocs/core/migrations/0004_ad-opt-out.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.9.12 on 2017-06-14 18:06
32
import annoying.fields
43
import django.db.models.deletion

readthedocs/core/migrations/0005_migrate-old-passwords.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.16 on 2018-10-11 17:28
32
from django.contrib.auth.hashers import make_password
43
from django.db import migrations

readthedocs/core/migrations/0006_remove_userprofile_allow_email.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
21
# Generated by Django 1.11.20 on 2019-03-01 17:30
3-
from __future__ import unicode_literals
4-
52
from django.db import migrations
63

74

readthedocs/core/static.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# -*- coding: utf-8 -*-
1+
"""
2+
Read the Docs custom static finders.
3+
4+
NOTE: I think we can probably remove it completely,
5+
since we are not storing these files anymore inside "media/"
6+
"""
7+
28
from django.contrib.staticfiles.finders import FileSystemFinder
39

410

readthedocs/core/tests/test_contact.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
User = get_user_model()
1111

1212
class TestContactUsers(TestCase):
13-
1413
def setUp(self):
15-
self.user = get(User, username='test', email='[email protected]')
16-
self.user_two = get(User, username='test2', email='[email protected]')
17-
self.user_three = get(User, username='test3', email='[email protected]')
18-
19-
@mock.patch('readthedocs.core.utils.contact.send_mail')
20-
@mock.patch.object(SiteBackend, 'send')
14+
self.user = get(User, username="test", email="[email protected]")
15+
self.user_two = get(User, username="test2", email="[email protected]")
16+
self.user_three = get(User, username="test3", email="[email protected]")
17+
18+
@mock.patch("readthedocs.core.utils.contact.send_mail")
19+
@mock.patch.object(SiteBackend, "send")
2120
def test_contact_users_dryrun(self, send_notification, send_mail):
2221
self.assertEqual(User.objects.all().count(), 3)
2322
resp = contact_users(

readthedocs/core/utils/extend.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21

32
"""Patterns for extending Read the Docs."""
43

readthedocs/doc_builder/signals.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# -*- coding: utf-8 -*-
21

32
"""Signals for adding custom context data."""
43

54
import django.dispatch
65

7-
86
finalize_sphinx_context_data = django.dispatch.Signal()

0 commit comments

Comments
 (0)