Skip to content

chore: remove all lint-amnesty annotations#38471

Open
feanil wants to merge 1 commit intomasterfrom
feanil/remove-lint-amnesty
Open

chore: remove all lint-amnesty annotations#38471
feanil wants to merge 1 commit intomasterfrom
feanil/remove-lint-amnesty

Conversation

@feanil
Copy link
Copy Markdown
Contributor

@feanil feanil commented Apr 29, 2026

Summary

  • Removes all # lint-amnesty, prefixes from Python files across the codebase (1225 files, ~4200 lines changed)
  • The underlying pylint suppression comments are fully preserved — only the lint-amnesty marker is dropped

Background

lint-amnesty annotations were added as temporary markers when pylint was first run in zero-tolerance mode, intended for later cleanup. Over time they've been copied into new code and are now causing lines to exceed the 120-char limit unnecessarily (the annotation itself adds length that pylint's line-too-long check was ignoring trailing comments for).

See OEP-0034 for historical context.

How it was generated

grep -r "lint-amnesty" --include="*.py" -l \
    | xargs sed -i \
        's/  # lint-amnesty,\?\s*/  # /g;
         s/# lint-amnesty,\?\s*/# /g;
         s/  # $//'

The first two expressions handle two spacing variants of the prefix while preserving whatever pylint disable follows. The comma is optional (\?) to catch the rare case where lint-amnesty appears without one. The third expression cleans up any trailing # left on lines where lint-amnesty was the entire comment.


# No enrollments
expected = hashlib.md5(self.user.username.encode('utf-8')).hexdigest() # lint-amnesty, pylint: disable=no-member
expected = hashlib.md5(self.user.username.encode('utf-8')).hexdigest() # pylint: disable=no-member
@@ -101,7 +101,7 @@
credit_request = create_credit_request(course_key, provider.provider_id, username)
return Response(credit_request)
except CreditApiBadRequest as ex:
raise InvalidCreditRequest(str(ex)) # lint-amnesty, pylint: disable=raise-missing-from # noqa: B904
raise InvalidCreditRequest(str(ex)) # pylint: disable=raise-missing-from # noqa: B904
except api.BlockLimitReachedError as exc:
log.exception(str(exc))
raise ValidationError(str(exc)) # lint-amnesty, pylint: disable=raise-missing-from # noqa: B904
raise ValidationError(str(exc)) # pylint: disable=raise-missing-from # noqa: B904
except api.InvalidNameError as exc:
log.exception(str(exc))
raise ValidationError(str(exc)) # lint-amnesty, pylint: disable=raise-missing-from # noqa: B904
raise ValidationError(str(exc)) # pylint: disable=raise-missing-from # noqa: B904
except api.LibraryBlockAlreadyExists as exc:
log.exception(str(exc))
raise ValidationError(str(exc)) # lint-amnesty, pylint: disable=raise-missing-from # noqa: B904
raise ValidationError(str(exc)) # pylint: disable=raise-missing-from # noqa: B904
@@ -346,7 +346,7 @@
try:
api.set_library_user_permissions(key, user, access_level=serializer.validated_data["access_level"])
except api.LibraryPermissionIntegrityError as err:
raise ValidationError(detail=str(err)) # lint-amnesty, pylint: disable=raise-missing-from # noqa: B904
raise ValidationError(detail=str(err)) # pylint: disable=raise-missing-from # noqa: B904
@@ -290,7 +290,7 @@
try:
api.update_library(key, **data)
except api.IncompatibleTypesError as err:
raise ValidationError({'type': str(err)}) # lint-amnesty, pylint: disable=raise-missing-from # noqa: B904
raise ValidationError({'type': str(err)}) # pylint: disable=raise-missing-from # noqa: B904
except InvalidPage as exc:
msg = self.invalid_page_message.format(
page_number=page_number, message=str(exc)
)
raise NotFound(msg) # lint-amnesty, pylint: disable=raise-missing-from # noqa: B904
raise NotFound(msg) # pylint: disable=raise-missing-from # noqa: B904
@@ -195,7 +195,7 @@
page_number=page_number, message=str(exc)
)
self.page.number = self.page.paginator.num_pages
raise NotFound(msg) # lint-amnesty, pylint: disable=raise-missing-from # noqa: B904
raise NotFound(msg) # pylint: disable=raise-missing-from # noqa: B904
@feanil
Copy link
Copy Markdown
Contributor Author

feanil commented May 1, 2026

The codeql issues are on existing code that's not changing but re-triggered because of the comment edits. I'm not gonna deal with them as a part of this PR.

@feanil feanil marked this pull request as ready for review May 1, 2026 20:45
We added those annotations when we first applied lint-amnesty to be able
to run pylint in zero-tolerance mode.  But now the comments keep getting
copied to other places and among other things causing lines to overrun
un-necessarily.

See
https://docs.openedx.org/projects/openedx-proposals/en/latest/archived/oep-0034-bp-lint-amnesty.html
for more historical details.

Generated with:

    grep -r "lint-amnesty" --include="*.py" -l \
        | xargs sed -i \
            's/  # lint-amnesty,\?\s*/  # /g;
             s/# lint-amnesty,\?\s*/# /g;
             s/  # $//'

The first two expressions are identical in effect but handle two spacing
variants: the common case where the comment is preceded by two spaces
("  # lint-amnesty, pylint: ...") and the rarer single-space case
("# lint-amnesty, pylint: ..."). Both strip the prefix while preserving
whatever pylint disable follows. The comma is made optional (",\?") to
handle the rare case where lint-amnesty appears without one. The third
expression cleans up any trailing "  #" left on lines where lint-amnesty
was the entire comment (e.g. ") -> None:  # lint-amnesty" becomes
") -> None:").

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@feanil feanil force-pushed the feanil/remove-lint-amnesty branch from 97d4180 to 77f213e Compare May 1, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants