Skip to content

ERA001: autofix removes valid comments that do not contain code or removes not everything #4845

@saippuakauppias

Description

@saippuakauppias

Example:

# Example of headers:
# X-token: <token_id>
# X-scope: no-scope
# End of comment about headers


# {
#    "some-key": {
#         '1': 1,
#         '2': 2',
#     }
# }


# some = 1
# awesome = 2
#
# foobar = 3
# barfoo = 4


# example code from IPython:
# In [20]: parse.parse_qsl('&l=55.123;123.1&count=3', keep_blank_values=1)
# Out[20]: [('l', '55.123'), ('123.1', ''), ('count', '3')]
# End of comment


# (пример, пример2) = (example1, example2)


# if not success:  # TODO: comment
#    errors.append('Ошибка: error')


# comment
# 1. [{пример первый}]
# 2. [[пример]]
# 3. [] - пусто


# Пример: {"description": "weight: "}


# comment about calculation
# 100 / 2 = 50
# end of comment


# comment:
# - tuple: ()
# - list: []
# - set: set()
# - dict: {}


# example of output:
# 'OK: message sent. Message-ID: 123456'


# MySQL: enum('positive', 'negative')


# query: lock + user.id

Ruff output:

$ ruff --fix --select ERA001 ruff_errors/ERA001.py
Found 24 errors (24 fixed, 0 remaining).

Contents of the file after fix:

# Example of headers:
# X-token: <token_id>
# End of comment about headers


#    "some-key": {


#


# example code from IPython:
# End of comment




# if not success:  # TODO: comment


# comment
# 1. [{пример первый}]
# 3. [] - пусто




# comment about calculation
# end of comment


# comment:


# example of output:



Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions