Skip to content

Commit

Permalink
Lint: one step forward through linting our code (#10129)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
humitos authored Mar 9, 2023
1 parent e39dbd9 commit 87b9959
Show file tree
Hide file tree
Showing 168 changed files with 61 additions and 294 deletions.
1 change: 0 additions & 1 deletion .github/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ todo:
blobLines: 7
caseSensitive: true
keyword: "TODO"

1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

2 changes: 1 addition & 1 deletion common
Submodule common updated 1 files
+17 −3 pre-commit-config.yaml
2 changes: 1 addition & 1 deletion docs/dev/design/new-sphinx-guides.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ highly recommended.
compilations of themes and extensions,
the development documentation.

.. note
.. note
- Looks like MathJax is enabled by default now? Can't see a reference in the docstrings
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/design/organizations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ How are we going to support organizations?
------------------------------------------

Currently only users can own projects in the community site.
With organizations this is going to change to:
With organizations this is going to change to:
Users and organizations can own projects.

With this, the migration process would be straightforward for the community site.
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/design/sphinx-jquery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ The minified jQuery JS file is ultimately included by calling `app.add_js_file <
get_jquery_url_path(),
loading_method="defer",
priority=200,
integrity="sha256-{}".format(get_jquery_sha256_checksum())
integrity="sha256-{}".format(get_jquery_sha256_checksum()),
)
Expand Down
1 change: 0 additions & 1 deletion docs/user/.tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,3 @@ file_filter = locale/<lang>/LC_MESSAGES/settings.po
source_file = _build/locale/settings.pot
source_lang = en
type = PO

2 changes: 1 addition & 1 deletion media/robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Disallow: /builds/
Disallow: /sustainability/click/

# This was hitting our site and causing a lot of issues
User-agent: AhrefsBot
User-agent: AhrefsBot
Disallow: /
1 change: 0 additions & 1 deletion prospector-more.yml

This file was deleted.

10 changes: 4 additions & 6 deletions readthedocs/api/v3/renderers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""Renders with some extra capabilities we require for our own purposes."""

import json

from rest_framework.compat import (
INDENT_SEPARATORS,
LONG_SEPARATORS,
SHORT_SEPARATORS,
)
from rest_framework.compat import INDENT_SEPARATORS, LONG_SEPARATORS, SHORT_SEPARATORS
from rest_framework.renderers import JSONRenderer


Expand All @@ -25,7 +23,7 @@ def render(self, data, accepted_media_type=None, renderer_context=None):
- sort_keys=True on json.dumps
- use str instead of six.text_types
https://github.com/encode/django-rest-framework/blob/master/rest_framework/renderers.py#L89
https://github.com/encode/django-rest-framework/blob/b7523f4/rest_framework/renderers.py#L84
"""
if data is None:
return bytes()
Expand Down
5 changes: 3 additions & 2 deletions readthedocs/builds/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import structlog
"""Django configuration for readthedocs.builds application."""

import structlog
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _

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

def ready(self):
import readthedocs.builds.tasks
import readthedocs.builds.tasks # noqa
1 change: 0 additions & 1 deletion readthedocs/builds/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import taggit.managers
from django.db import migrations, models

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models

import readthedocs.builds.models
Expand Down
1 change: 0 additions & 1 deletion readthedocs/builds/migrations/0003_add-cold-storage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.12 on 2017-10-09 20:14
from django.db import migrations, models

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

Expand Down
1 change: 0 additions & 1 deletion readthedocs/builds/migrations/0005_remove-version-alias.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-10-17 04:20
from django.db import migrations, models

Expand Down
1 change: 0 additions & 1 deletion readthedocs/builds/migrations/0006_add_config_field.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-02 13:24
import jsonfield.fields
from django.db import migrations
Expand Down
5 changes: 1 addition & 4 deletions readthedocs/builds/migrations/0007_add-automation-rules.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-04-25 23:04
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import django_extensions.db.fields
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
3 changes: 0 additions & 3 deletions readthedocs/builds/migrations/0008_remove-version-tags.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-06-28 16:29
from __future__ import unicode_literals

from django.db import migrations


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.21 on 2019-07-04 13:10
from __future__ import unicode_literals

from django.db import migrations, models


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.22 on 2019-07-25 17:24
from __future__ import unicode_literals

from django.db import migrations, models


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.23 on 2019-10-07 23:32
from __future__ import unicode_literals

from django.db import migrations, models


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.25 on 2019-11-05 23:54
from __future__ import unicode_literals

from django.db import migrations, models


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.27 on 2020-01-14 17:37
from __future__ import unicode_literals

from django.db import migrations, models


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.27 on 2020-01-14 17:40

from django.db import migrations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Generated by Django 2.2.16 on 2020-11-18 21:52

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


class Migration(migrations.Migration):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by Django 3.2.11 on 2022-01-31 12:12

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


class Migration(migrations.Migration):
Expand Down
2 changes: 0 additions & 2 deletions readthedocs/builds/tests/test_celery_task_router.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import django_dynamic_fixture as fixture
from django.conf import settings
from django.test import TestCase
from django.test.utils import override_settings

from readthedocs.builds.constants import EXTERNAL
from readthedocs.builds.models import Build, Version
Expand Down
1 change: 0 additions & 1 deletion readthedocs/builds/version_slug.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

"""
Contains logic for handling version slugs.
Expand Down
1 change: 0 additions & 1 deletion readthedocs/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

"""Logic to parse and validate ``readthedocs.yaml`` file."""
from .config import * # noqa
Expand Down
1 change: 0 additions & 1 deletion readthedocs/config/find.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

"""Helper functions to search files."""

Expand Down
1 change: 0 additions & 1 deletion readthedocs/config/parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

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

Expand Down
1 change: 0 additions & 1 deletion readthedocs/config/tests/test_find.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os

from readthedocs.config.find import find_one
Expand Down
1 change: 0 additions & 1 deletion readthedocs/config/tests/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from io import StringIO

from pytest import raises
Expand Down
1 change: 0 additions & 1 deletion readthedocs/config/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from .utils import apply_fs


Expand Down
2 changes: 0 additions & 2 deletions readthedocs/config/tests/test_validation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os

from unittest.mock import patch
from pytest import raises

from readthedocs.config.validation import (
Expand Down
3 changes: 1 addition & 2 deletions readthedocs/config/tests/test_yaml_loader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from readthedocs.doc_builder.backends.mkdocs import (
ProxyPythonName,
yaml_dump_safely,
yaml_load_safely,
ProxyPythonName
)

content = '''
Expand Down Expand Up @@ -35,4 +35,3 @@ def test_yaml_load_safely():
def test_yaml_dump_safely():
data = yaml_load_safely(content)
assert yaml_load_safely(yaml_dump_safely(data)) == data

1 change: 0 additions & 1 deletion readthedocs/config/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

def apply_fs(tmpdir, contents):
"""
Expand Down
6 changes: 2 additions & 4 deletions readthedocs/core/apps.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""App configurations for core app."""

import structlog

from django.apps import AppConfig

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

def ready(self):
import readthedocs.core.signals # noqa

# Import `readthedocs.core.logs` to set up structlog
import readthedocs.core.logs # noqa
import readthedocs.core.signals # noqa

try:
import readthedocsext.monitoring.metrics.tasks
import readthedocsext.monitoring.metrics.tasks # noqa
except (ModuleNotFoundError, ImportError):
log.info('Metrics tasks could not be imported.')
1 change: 0 additions & 1 deletion readthedocs/core/backends.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

"""Email backends for core app."""

Expand Down
1 change: 0 additions & 1 deletion readthedocs/core/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

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

Expand Down
1 change: 0 additions & 1 deletion readthedocs/core/fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

"""Shared model fields and defaults."""

Expand Down
1 change: 0 additions & 1 deletion readthedocs/core/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.conf import settings
from django.db import migrations, models

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.conf import settings
from django.db import migrations, models

Expand Down
1 change: 0 additions & 1 deletion readthedocs/core/migrations/0003_add_banned_status.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models


Expand Down
1 change: 0 additions & 1 deletion readthedocs/core/migrations/0004_ad-opt-out.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.12 on 2017-06-14 18:06
import annoying.fields
import django.db.models.deletion
Expand Down
1 change: 0 additions & 1 deletion readthedocs/core/migrations/0005_migrate-old-passwords.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-10-11 17:28
from django.contrib.auth.hashers import make_password
from django.db import migrations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-03-01 17:30
from __future__ import unicode_literals

from django.db import migrations


Expand Down
8 changes: 7 additions & 1 deletion readthedocs/core/static.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# -*- coding: utf-8 -*-
"""
Read the Docs custom static finders.
NOTE: I think we can probably remove it completely,
since we are not storing these files anymore inside "media/"
"""

from django.contrib.staticfiles.finders import FileSystemFinder


Expand Down
13 changes: 6 additions & 7 deletions readthedocs/core/tests/test_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
User = get_user_model()

class TestContactUsers(TestCase):

def setUp(self):
self.user = get(User, username='test', email='[email protected]')
self.user_two = get(User, username='test2', email='[email protected]')
self.user_three = get(User, username='test3', email='[email protected]')
@mock.patch('readthedocs.core.utils.contact.send_mail')
@mock.patch.object(SiteBackend, 'send')
self.user = get(User, username="test", email="[email protected]")
self.user_two = get(User, username="test2", email="[email protected]")
self.user_three = get(User, username="test3", email="[email protected]")

@mock.patch("readthedocs.core.utils.contact.send_mail")
@mock.patch.object(SiteBackend, "send")
def test_contact_users_dryrun(self, send_notification, send_mail):
self.assertEqual(User.objects.all().count(), 3)
resp = contact_users(
Expand Down
1 change: 0 additions & 1 deletion readthedocs/core/utils/extend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

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

Expand Down
2 changes: 0 additions & 2 deletions readthedocs/doc_builder/signals.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-

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

import django.dispatch


finalize_sphinx_context_data = django.dispatch.Signal()
Loading

0 comments on commit 87b9959

Please sign in to comment.