Skip to content

Use Ruff for linting #12037

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

Merged
merged 3 commits into from
Mar 11, 2025
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .flake8

This file was deleted.

1 change: 0 additions & 1 deletion .isort.cfg

This file was deleted.

1 change: 0 additions & 1 deletion .pep8

This file was deleted.

1 change: 1 addition & 0 deletions .ruff.toml
2 changes: 1 addition & 1 deletion common
Submodule common updated 2 files
+38 −0 .ruff.toml
+10 −62 pre-commit-config.yaml
2 changes: 1 addition & 1 deletion docs/_static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
text-rendering: auto;
-webkit-font-smoothing: antialiased;

}
}
1 change: 0 additions & 1 deletion media/css/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@
.ui-autocomplete { background: #fff; text-align: left; border: 1px solid #bfbfbf; }
.ui-state-hover { background: #eee; }
.ui-menu-item a { display: block; padding: 3px 10px; }

2 changes: 1 addition & 1 deletion media/javascript/searchtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,4 +512,4 @@ var Search = {

$(document).ready(function() {
Search.init();
});
});
1 change: 0 additions & 1 deletion prospector.yml

This file was deleted.

1 change: 0 additions & 1 deletion readthedocs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"""Read the Docs."""


__version__ = "12.0.0"
1 change: 1 addition & 0 deletions readthedocs/allauth/providers/githubapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

from readthedocs.allauth.providers.githubapp.provider import GitHubAppProvider


urlpatterns = default_urlpatterns(GitHubAppProvider)
6 changes: 2 additions & 4 deletions readthedocs/allauth/providers/githubapp/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""Copied from allauth.socialaccount.providers.github.views."""

from allauth.socialaccount.providers.github.views import GitHubOAuth2Adapter
from allauth.socialaccount.providers.oauth2.views import (
OAuth2CallbackView,
OAuth2LoginView,
)
from allauth.socialaccount.providers.oauth2.views import OAuth2CallbackView
from allauth.socialaccount.providers.oauth2.views import OAuth2LoginView


class GitHubAppOAuth2Adapter(GitHubOAuth2Adapter):
Expand Down
1 change: 0 additions & 1 deletion readthedocs/analytics/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class AnalyticsAppConfig(AppConfig):

"""Analytics app init code."""

default_auto_field = "django.db.models.BigAutoField"
Expand Down
7 changes: 5 additions & 2 deletions readthedocs/analytics/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# Generated by Django 2.2.12 on 2020-05-19 00:45

import datetime
from django.db import migrations, models

import django.db.models.deletion
from django.db import migrations
from django.db import models
from django_safemigrate import Safe


class Migration(migrations.Migration):
safe = Safe.after_deploy
initial = True

dependencies = [
Expand Down
14 changes: 6 additions & 8 deletions readthedocs/analytics/migrations/0002_track_status_code.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Generated by Django 3.2.12 on 2022-03-29 17:51

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


class Migration(migrations.Migration):
safe = Safe.after_deploy
dependencies = [
("builds", "0041_track_task_id"),
("projects", "0087_use_booleanfield_null"),
Expand All @@ -25,16 +27,12 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name="pageview",
name="status",
field=models.PositiveIntegerField(
default=200, help_text="HTTP status code"
),
field=models.PositiveIntegerField(default=200, help_text="HTTP status code"),
),
migrations.AlterField(
model_name="pageview",
name="path",
field=models.CharField(
help_text="Path relative to the version.", max_length=4096
),
field=models.CharField(help_text="Path relative to the version.", max_length=4096),
),
migrations.AlterField(
model_name="pageview",
Expand Down
6 changes: 4 additions & 2 deletions readthedocs/analytics/migrations/0003_remove_index.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Generated by Django 3.2.13 on 2022-05-31 15:22

import datetime

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


class Migration(migrations.Migration):
safe = Safe.after_deploy
dependencies = [
("analytics", "0002_track_status_code"),
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by Django 3.2.13 on 2022-07-06 21:11

from django.db import migrations
from django.db.models import Count
from django_safemigrate import Safe


def forwards_func(apps, schema_editor):
Expand Down Expand Up @@ -29,6 +29,7 @@ def forwards_func(apps, schema_editor):


class Migration(migrations.Migration):
safe = Safe.after_deploy
dependencies = [
("analytics", "0003_remove_index"),
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Generated by Django 3.2.13 on 2022-07-06 19:29

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


class Migration(migrations.Migration):
safe = Safe.after_deploy
dependencies = [
("analytics", "0004_merge_duplicate_records"),
]
Expand Down
6 changes: 4 additions & 2 deletions readthedocs/analytics/migrations/0006_alter_pageview_id.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Generated by Django 3.2.15 on 2022-10-18 15:25

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


class Migration(migrations.Migration):
safe = Safe.after_deploy
dependencies = [
("analytics", "0005_add_unique_constraint"),
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Generated by Django 3.2.19 on 2023-06-13 11:12

import datetime

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


class Migration(migrations.Migration):
safe = Safe.after_deploy
dependencies = [
("analytics", "0006_alter_pageview_id"),
]
Expand Down
10 changes: 4 additions & 6 deletions readthedocs/analytics/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Analytics modeling to help understand the projects on Read the Docs."""

import datetime
from collections import namedtuple
from urllib.parse import urlparse
Expand All @@ -10,7 +11,8 @@

from readthedocs.builds.models import Version
from readthedocs.core.resolver import Resolver
from readthedocs.projects.models import Feature, Project
from readthedocs.projects.models import Feature
from readthedocs.projects.models import Project


def _last_30_days_iter():
Expand All @@ -22,7 +24,6 @@ def _last_30_days_iter():


class PageViewManager(models.Manager):

"""Manager for PageView model."""

def register_page_view(self, project, version, filename, path, status):
Expand Down Expand Up @@ -53,7 +54,6 @@ def register_page_view(self, project, version, filename, path, status):


class PageView(models.Model):

"""PageView counts per day for a project, version, and path."""

project = models.ForeignKey(
Expand Down Expand Up @@ -103,9 +103,7 @@ class Meta:
]

@classmethod
def top_viewed_pages(
cls, project, since=None, limit=10, status=200, per_version=False
):
def top_viewed_pages(cls, project, since=None, limit=10, status=200, per_version=False):
"""
Returns top pages according to view counts.

Expand Down
6 changes: 4 additions & 2 deletions readthedocs/analytics/proxied_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Analytics views that are served from the same domain as the docs."""

from functools import lru_cache
from urllib.parse import urlparse

Expand All @@ -12,16 +13,17 @@
from readthedocs.analytics.models import PageView
from readthedocs.api.v2.permissions import IsAuthorizedToViewVersion
from readthedocs.core.mixins import CDNCacheControlMixin
from readthedocs.core.unresolver import UnresolverError, unresolve
from readthedocs.core.unresolver import UnresolverError
from readthedocs.core.unresolver import unresolve
from readthedocs.core.utils.extend import SettingsOverrideObject
from readthedocs.core.utils.requests import is_suspicious_request
from readthedocs.projects.models import Project


log = structlog.get_logger(__name__) # noqa


class BaseAnalyticsView(CDNCacheControlMixin, APIView):

"""
Track page views.

Expand Down
1 change: 1 addition & 0 deletions readthedocs/analytics/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import readthedocs
from readthedocs.worker import app


DEFAULT_PARAMETERS = {
"v": "1", # analytics version (always 1)
"aip": "1", # anonymize IP
Expand Down
4 changes: 3 additions & 1 deletion readthedocs/analytics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import structlog
from django.conf import settings
from django.utils.crypto import get_random_string
from django.utils.encoding import force_bytes, force_str
from django.utils.encoding import force_bytes
from django.utils.encoding import force_str
from user_agents import parse


log = structlog.get_logger(__name__) # noqa


Expand Down
6 changes: 3 additions & 3 deletions readthedocs/api/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
from django.http import Http404
from django.utils.functional import cached_property

from readthedocs.core.unresolver import UnresolverError, unresolve
from readthedocs.core.unresolver import UnresolverError
from readthedocs.core.unresolver import unresolve
from readthedocs.core.utils import get_cache_tag
from readthedocs.proxito.cache import add_cache_tags


log = structlog.get_logger(__name__)


class CDNCacheTagsMixin:

"""
Add cache tags for project and version to the response of this view.

Expand Down Expand Up @@ -64,7 +65,6 @@ def _get_cache_tags(self):


class EmbedAPIMixin:

"""
Helper for EmbedAPI v2 and v3.

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


class TimeoutAdapter:

"""
Adapter to inject ``timeout`` to all the requests.

Expand Down
8 changes: 5 additions & 3 deletions readthedocs/api/v2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
import structlog
from django.conf import settings
from rest_framework.renderers import JSONRenderer
from slumber import API, serialize
from slumber import API
from slumber import serialize
from urllib3.util.retry import Retry

from .adapters import TimeoutHostHeaderSSLAdapter, TimeoutHTTPAdapter
from .adapters import TimeoutHostHeaderSSLAdapter
from .adapters import TimeoutHTTPAdapter


log = structlog.get_logger(__name__)


class DrfJsonSerializer(serialize.JsonSerializer):

"""Additional serialization help from the DRF renderer."""

key = "json-drf"
Expand Down
6 changes: 4 additions & 2 deletions readthedocs/api/v2/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Generated by Django 3.2.18 on 2023-05-31 20:40

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


class Migration(migrations.Migration):
safe = Safe.after_deploy
initial = True

dependencies = [
Expand Down
4 changes: 2 additions & 2 deletions readthedocs/api/v2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from django.db import models
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from rest_framework_api_key.models import AbstractAPIKey, BaseAPIKeyManager
from rest_framework_api_key.models import AbstractAPIKey
from rest_framework_api_key.models import BaseAPIKeyManager

from readthedocs.projects.models import Project

Expand All @@ -28,7 +29,6 @@ def create_key(self, project):


class BuildAPIKey(AbstractAPIKey):

"""
API key for securely interacting with the API from the builders.

Expand Down
Loading