Draft
Conversation
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 <noreply@anthropic.com>
|
|
||
| # 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 | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
# lint-amnesty,prefixes from Python files across the codebase (1225 files, ~4200 lines changed)lint-amnestymarker is droppedBackground
lint-amnestyannotations 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'sline-too-longcheck was ignoring trailing comments for).See OEP-0034 for historical context.
How it was generated
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 wherelint-amnestyappears without one. The third expression cleans up any trailing#left on lines wherelint-amnestywas the entire comment.