Skip to content

Commit

Permalink
Enable ruff's N (pep8 naming) set of rules
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Oct 24, 2024
1 parent 8ae69dd commit 9a12803
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lms/db/_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlalchemy.orm import Session


class CouldNotAcquireLock(Exception):
class CouldNotAcquireLock(Exception): # noqa: N818
"""A lock could not be immediately acquired."""


Expand Down
2 changes: 1 addition & 1 deletion lms/models/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ReusedConsumerKey(Exception):
class ReusedConsumerKey(Exception): # noqa: N818
"""Application Instance launched in a different LMS install."""

def __init__(self, existing_guid, new_guid):
Expand Down
6 changes: 3 additions & 3 deletions lms/services/application_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
LOG = getLogger(__name__)


class ApplicationInstanceNotFound(Exception):
class ApplicationInstanceNotFound(Exception): # noqa: N818
"""The requested ApplicationInstance wasn't found in the database."""


class AccountDisabled(SerializableError):
class AccountDisabled(SerializableError): # noqa: N818
"""Indicate that we have disabled this account through it's org."""

def __init__(self, application_instance: ApplicationInstance):
Expand All @@ -34,7 +34,7 @@ def __init__(self, application_instance: ApplicationInstance):
)


class ProvisioningDisabled(SerializableError):
class ProvisioningDisabled(SerializableError): # noqa: N818
"""
Indicate that provisioning is not enabled for this instance.
Expand Down
8 changes: 4 additions & 4 deletions lms/services/blackboard_api/_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class Meta:
name = fields.Str(required=True)
modified = fields.Str(required=True)
type = fields.Str(required=True)
mimeType = fields.Str()
mimeType = fields.Str() # noqa: N815
size = fields.Integer()
parentId = fields.Str()
parentId = fields.Str() # noqa: N815

results = fields.List(fields.Nested(FileSchema), required=True)

Expand All @@ -37,7 +37,7 @@ def post_load(self, data, **_kwargs):
class BlackboardPublicURLSchema(RequestsResponseSchema):
"""Schema for Blackboard /courses/{courseId}/resources/{resourceId} responses."""

downloadUrl = fields.Str(required=True)
downloadUrl = fields.Str(required=True) # noqa: N815

@post_load
def post_load(self, data, **_kwargs):
Expand Down Expand Up @@ -74,7 +74,7 @@ class Meta:

id = fields.Str(required=True)
name = fields.Str(required=True)
groupSetId = fields.Str(required=False, allow_none=True)
groupSetId = fields.Str(required=False, allow_none=True) # noqa: N815
enrollment = fields.Nested(EnrollmentSchema, required=True)

results = fields.List(fields.Nested(GroupSchema), required=True)
Expand Down
4 changes: 2 additions & 2 deletions lms/services/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,14 @@ def __init__(
self.details = details


class FileNotFoundInCourse(SerializableError):
class FileNotFoundInCourse(SerializableError): # noqa: N818
"""A file wasn't found in the current course."""

def __init__(self, error_code: str, document_id):
super().__init__(error_code=error_code, details={"document_id": document_id})


class StudentNotInCourse(SerializableError):
class StudentNotInCourse(SerializableError): # noqa: N818
"""A student is no longer in the current course."""

def __init__(self, grading_id):
Expand Down
2 changes: 1 addition & 1 deletion lms/services/jstor/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from lms.views.helpers import via_url


class ArticleNotFound(SerializableError):
class ArticleNotFound(SerializableError): # noqa: N818
def __init__(self, article_id):
super().__init__(message=f"Article '{article_id}' not found")

Expand Down
4 changes: 2 additions & 2 deletions lms/services/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
LOG = getLogger(__name__)


class InvalidOrganizationParent(Exception):
class InvalidOrganizationParent(Exception): # noqa: N818
"""The requested Organization wasn't found or isn't an eligible parent."""


class InvalidPublicId(Exception):
class InvalidPublicId(Exception): # noqa: N818
"""Indicate an error with the specified public id."""


Expand Down
2 changes: 1 addition & 1 deletion lms/services/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from lms.services.upsert import bulk_upsert


class UserNotFound(Exception):
class UserNotFound(Exception): # noqa: N818
"""The requested User wasn't found in the database."""


Expand Down
2 changes: 1 addition & 1 deletion lms/services/vitalsource/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
LOG = logging.getLogger(__name__)


class BookNotFound(SerializableError):
class BookNotFound(SerializableError): # noqa: N818
def __init__(self, book_id):
super().__init__(message=f"Book {book_id} not found")

Expand Down
2 changes: 1 addition & 1 deletion lms/services/vitalsource/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class VitalSourceError(SerializableError):
"""Indicate a failure in the VitalSource service or client."""


class VitalSourceMalformedRegex(VitalSourceError):
class VitalSourceMalformedRegex(VitalSourceError): # noqa: N818
"""An issue with the user regex."""

def __init__(self, description, pattern):
Expand Down
2 changes: 1 addition & 1 deletion lms/services/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""YouTube's API base URL"""


class VideoNotFound(SerializableError):
class VideoNotFound(SerializableError): # noqa: N818
def __init__(self, video_id):
super().__init__(
error_code="youtube_video_not_found", details={"video_id": video_id}
Expand Down
2 changes: 1 addition & 1 deletion lms/views/api/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class APISyncSchema(PyramidRequestSchema):
context_id = fields.Str(required=True)
group_set_id = fields.Str(required=False, allow_none=True)
group_info = fields.Dict(required=True)
gradingStudentId = fields.Str(required=False, allow_none=True)
gradingStudentId = fields.Str(required=False, allow_none=True) # noqa: N815


@view_config(
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ select = [
"R", "PLR", # https://docs.astral.sh/ruff/rules/#refactor-r
"C", "PLC", # https://docs.astral.sh/ruff/rules/#convention-c
"SLF", # flake-8-self
"N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n

"RUF100", # unused-noqa
]
Expand Down

0 comments on commit 9a12803

Please sign in to comment.