Skip to content
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

Pack of fuzzer Autofix/Infinite loop errors #7455

Closed
33 of 50 tasks
qarmin opened this issue Sep 17, 2023 · 58 comments
Closed
33 of 50 tasks

Pack of fuzzer Autofix/Infinite loop errors #7455

qarmin opened this issue Sep 17, 2023 · 58 comments
Labels
bug Something isn't working fuzzer Surfaced via fuzzing.

Comments

@qarmin
Copy link

qarmin commented Sep 17, 2023

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select B006 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

class SearchableCollection:
   def __init__(self,list_initial=[], master=None):
        s

error

/home/rafal/test/tmp_folder/FILE_R1057.py:2:36: B006 Do not use mutable data structures for argument defaults
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R1057.py`, the rule codes B006, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select B009 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

def test_rpc_callable():
    assert getattr(func, '_rpc')is True

error

/home/rafal/test/tmp_folder/FILE_R2917.py:2:12: B009 Do not call `getattr` with a constant attribute value. It is not any safer than normal property access.
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R2917.py`, the rule codes B009, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select C402 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

def middle_east_parsed_date(text_date, kwargs):
    dict_month_abbr_numeric = dict((*v, k) for k, v in enumerate(calendar.month_abbr))

error

/home/rafal/test/tmp_folder/FILE_R2713.py:2:31: C402 Unnecessary generator (rewrite as a `dict` comprehension)
Found 1 error.

error: Failed to create fix for UnnecessaryGeneratorDict: Expected tuple to contain two elements

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select C413 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

class BNode (object) :
            self.by_gain = list \
                (sorted
                  ( self.candidates.keys ()
                  )
                )

error

/home/rafal/test/tmp_folder/FILE_R162.py:2:28: C413 Unnecessary `list` call around `sorted()`
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R162.py`, the rule codes C413, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select C417 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

class Item():
        if ((item := item.capitalize()) in
            (item_list := list(map(lambda item_tuple: item_tuple[0],
                                   search_results := _search_item_data(item))))):
            self.__id = self.__item_data[1]

error

/home/rafal/test/tmp_folder/FILE_R872.py:3:27: C417 Unnecessary `map` usage (rewrite using a `list` comprehension)
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R872.py`, the rule codes C417, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select C418 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

class PID(Controller, Base):
            raise ValueError(f"The number of set points is greater than 1, but the supplied matrix for "
                             f"{dict({'k_p': 'K_P', 't_i': 'T_I', 't_d': 'T_D'})[which]} is not a diagonal matrix. "
                             f"Coupled multi-variable control is not supported at the moment.")

error

/home/rafal/test/tmp_folder/FILE_R516.py:3:33: C418 Unnecessary `dict` literal passed to `dict()` (remove the outer call to `dict()`)
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R516.py`, the rule codes C418, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select D201 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

def maybe_async(callable_, *args, **kwargs):\

    """
    Turn a callable into a coroutine if it isn't
    """
    return asyncio.coroutine(callable_)(*args, **kwargs)

error

/home/rafal/test/tmp_folder/FILE_R132.py:3:5: D201 No blank lines allowed before function docstring (found 1)
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R132.py`, the rule codes D201, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select D211 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

class Protocol4Enum(object):\

    """Implementation of the 'Protocol4' enum.
    """
    TCP = 'TCP'

error

/home/rafal/test/tmp_folder/FILE_R1422.py:3:5: D211 No blank lines allowed before class docstring
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R1422.py`, the rule codes D211, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select E713 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

class Bitcoin(Base):
		if not('name' in request)or not request['name']:
			request['name'] = None

error

/home/rafal/test/tmp_folder/FILE_R3518.py:2:10: E713 Test for membership should be `not in`
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R3518.py`, the rule codes E713, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select E714 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured


# defaults

MOJEID_LOGIN_METHOD = "ANY"
MOJEID_INSTANCE_PRODUCTION = False
MOJEID_MAX_AUTH_AGE = None
MOJEID_SESSION_NEXT_PAGE_ATTR = 'mojeid_next_page'

class Settings(object):
    def __getattr__(self, name):
        try:
            attr = getattr(settings, name)
        except AttributeError:
            try:
                attr = globals()[name]
            except KeyError:
                raise AttributeError(
                    "'Settings' object has no attribute '%s'" % name)

        # validate
        if name == 'MOJEID_LOGIN_METHOD' and attr not in ("ANY", "CERT", "OTP"):
            raise ImproperlyConfigured(
                "Invalid MOJEID_LOGIN_METHOD '%s'" % attr)

        if name == 'MOJEID_MAX_AUTH_AGE' and not (
                attr is Noneor
                (isinstance(attr, int) and attr >= 0)):
            raise ImproperlyConfigured(
                "MOJEID_MAX_AUTH_AGE must be a positive integer (>= 0) or None")
        return attr

mojeid_settings = Settings()

error

/home/rafal/test/tmp_folder/FILE_R3249.py:29:17: E714 Test for object identity should be `is not`
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R3249.py`, the rule codes E714, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select PIE804,RUF100 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

from d3r.molfilevalidator import D3RMoleculeFromMolFileViaOpeneyeFactory \
    # noqa: E402
class TestMolFileValidator(unittest.TestCase):
            factory = D3RMoleculeFromMolFileViaOpeneyeFactory()

error

/home/rafal/test/tmp_folder/FILE_R3421.py:2:5: RUF100 Unused `noqa` directive (non-enabled: `E402`)
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R3421.py`, the rule codes RUF100, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select PLR0133 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

def test_ffpuppet_22(mocker, tmp_path):
            log_fp.write(
            )  # must be 2nd line
            for _ in range(4):  # pad out to 6 lines
                log_fp.write("filler line\n")
            log_fp.write(
                "==70811==ERROR: AddressSanitizer:"
    is not False         )  # must be 2nd line

error

/home/rafal/test/tmp_folder/FILE_R895.py:7:17: PLR0133 Two constants compared in a comparison, consider replacing `"==70811==ERROR: AddressSanitizer:" is not False`
Found 1 error.

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select PT009 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

class test_compare_ExpCM_emp_phi_with_without_divpress(unittest.TestCase):
                        (self.assertTrue(
                            "piAx_piAy_beta[r][x][y] = {17}".format(
                                    self.model.piAx_piAy_beta[r][x][y])))

error

/home/rafal/test/tmp_folder/FILE_R1333.py:2:26: PT009 Use a regular `assert` instead of unittest-style `assertTrue`
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R1333.py`, the rule codes PT009, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select RUF005 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

def bash_completion():
    '''
    '''
    return '\n'.join(
        (
            f'''        then cat << EOF\n{borgmatic.commands.completion.actions.upgrade_message(
                    'sudo sh -c "borgmatic --bash-completion > $BASH_SOURCE"',
                )}\nEOF''',
        )
        + tuple(
            ),
        )

error

/home/rafal/test/tmp_folder/FILE_R793.py:5:9: RUF005 Consider iterable unpacking instead of concatenation
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R793.py`, the rule codes RUF005, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select SIM101 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

class SDOF_Model():
        if(isinstance(self.k, int)) or (isinstance(self.k, float)):
            print(f"Constant Mutual Stiffness = {self.k} lb/ft ")

error

/home/rafal/test/tmp_folder/FILE_R1009.py:2:11: SIM101 Multiple `isinstance` calls for expression, merge into a single call
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R1009.py`, the rule codes SIM101, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select SIM105 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

from serial.tools.list_ports import comports \

def listEBBports():
    try:
        com_ports_list = list(comports())
    except TypeError:
        try:
            port_name.close()
        except serial.SerialException:
            pass

error

/home/rafal/test/tmp_folder/FILE_R3096.py:7:9: SIM105 Use `contextlib.suppress(serial.SerialException)` instead of `try`-`except`-`pass`
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R3096.py`, the rule codes SIM105, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select SIM208 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

def match_type( param_name, all_param_values, configs, validate_uris=True, search_paths=True, search_subdirs=True, allow_remote_uri=True, allow_local_path=True, input_dir=""):
    type_matching_functions = { 
    }
    assert not ((value[0] == "null" or value[0] == "") and 
        not configs[param_name]["null_allowed"]
    ), "parameter is \"null\" but this is not allowed."
    assert not (
        not configs[param_name]["is_array"]# fmt: on and 
        (value[0] == "itemNull")
    ), "Parameter is set to \"itemNull\" but it is not an array/list."

error

/home/rafal/test/tmp_folder/FILE_R1071.py:7:12: SIM208 Use `configs[param_name]["is_array"](value[0] == "itemNull")` instead of `not (not configs[param_name]["is_array"](value[0] == "itemNull"))`
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R1071.py`, the rule codes SIM208, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select TCH001 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

from __future__ import annotations
if sys.implementation.name == "circuitpython" and sys.implementation.version[0] <= 4:
    raise ImportError(
    )
from .advertising import Advertisement
try:
    from typing import Iterator, NoReturn, Optional, Tuple, Type, TYPE_CHECKING, Union
    if TYPE_CHECKING:
        from adafruit_ble.uuid import UUID
except ImportError:
    def start_scan(
    ) -> Iterator[Advertisement]:
        """
        """

error

/home/rafal/test/tmp_folder/FILE_R1117.py:4:30: TCH001 Move application import `.advertising.Advertisement` into a type-checking block
Found 101 errors (100 fixed, 1 remaining).


error: Failed to converge after 100 iterations.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BInfinite%20loop%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R1117.py`, the rule codes TCH001, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select TCH002 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

import debus
try:
    import typing
except:
    def send(self, message: 'debus.Message'):
        buf = OutputBuffer()

error

/home/rafal/test/tmp_folder/FILE_R35.py:3:12: TCH002 Move third-party import `debus` into a type-checking block
Found 101 errors (100 fixed, 1 remaining).


error: Failed to converge after 100 iterations.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BInfinite%20loop%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R35.py`, the rule codes TCH002, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select UP003 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

class RDirNode(object):
        assert isinstance(fullname, type("")is not True)

error

/home/rafal/test/tmp_folder/FILE_R1822.py:2:37: UP003 Use `str` instead of `type(...)`
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R1822.py`, the rule codes UP003, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select UP012 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

def _match_ignore(line):
	input=stdin and'\n'.encode()or None

error

/home/rafal/test/tmp_folder/7386394.py:2:17: UP012 Unnecessary call to `encode` as UTF-8
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/7386394.py`, the rule codes UP012, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select UP025 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

class PerDurationDatabase:
                raise ValueError(
                    u"Transmit rate conflict:"
                    f" {measurement!r} {previous_tr!r}"
                )

error

/home/rafal/test/tmp_folder/166_IDX_0_RAND_17972367865119120768684.py:3:23: UP025 Remove unicode literals from strings
/home/rafal/test/tmp_folder/166_IDX_0_RAND_17972367865119120768684.py:4:39: UP025 Remove unicode literals from strings
Found 2 errors.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/166_IDX_0_RAND_17972367865119120768684.py`, the rule codes UP025, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select UP028 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

def scraper(keyword, csv=True):
    for course in go_t,o_course(driver, keyword, csv):
        yield course

error

/home/rafal/test/tmp_folder/FILE_R165.py:2:5: UP028 Replace `yield` over `for` loop with `yield from`
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R165.py`, the rule codes UP028, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select E703,F407 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

class AFT_FSDK_Version(Structure):
    _fields_ = [('lCodebase',c_int32),('lMajor',c_int32),('lMinor',c_int32),('lBuild',c_int32),
               ('Version',c_har_p),('BuildDate',c_char_p),('CopyRight',c_char_p)]
AFT_FSDK_OPF_90_ONLY = 0x2;       90; 90; ...

error

/home/rafal/test/tmp_folder/FILE_R71.py:4:41: E703 Statement ends with an unnecessary semicolon
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R71.py`, the rule codes E703, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select EM103 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

class FieldXmlMapper(Mapper):
            raise exc.SerializationError(
            )
            if self.required:\
                raise exc.SerializationError("required element '{}' is not set".format(name))

error

/home/rafal/test/tmp_folder/FILE_R4553.py:5:46: EM103 Exception must not use a `.format()` string directly, assign to variable first
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R4553.py`, the rule codes EM103, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 17, 2023

Ruff 0.0.290 (latest changes from main branch)

ruff  *.py --select PLR1701 --no-cache --fix --preview

file content(at least simple cpython script shows that this is valid python file):

class SDOF_Model():
        if(isinstance(self.k, int)) or (isinstance(self.k, float)):
            print(f"Constant Mutual Stiffness = {self.k} lb/ft ")

error

/home/rafal/test/tmp_folder/FILE_R1009.py:2:11: PLR1701 Merge `isinstance` calls: `isinstance(self.k, (float, int))`
Found 1 error.


error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `/home/rafal/test/tmp_folder/FILE_R1009.py`, the rule codes PLR1701, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Sep 29, 2023

Ruff 0.0.291 (latest changes from main branch)

ruff  *.py --select PIE790 --no-cache --fix --preview

file content:

for i in range(2):
    pass

    pass

error

/home/rafal/test/tmp_folder/F_NAME_173190734823555694175982.py:2:5: PIE790 Unnecessary `pass` statement
/home/rafal/test/tmp_folder/F_NAME_173190734823555694175982.py:4:5: PIE790 Unnecessary `pass` statement
Found 2 errors.

error: Fix introduced a syntax error in `/home/rafal/test/tmp_folder/F_NAME_173190734823555694175982.py` with rule codes PIE790: unindent does not match any outer indentation level at byte offset 19
---
for i in range(2):


---

@qarmin
Copy link
Author

qarmin commented Sep 29, 2023

Ruff 0.0.291 (latest changes from main branch)

ruff  *.py --select PT006 --no-cache --fix --preview

file content:

import pytest
@pytest.mark.parametrize(
    [
        (  # ts1 - load 2 dgs, extract 2 tables with interpolation
        (  # ts3 - load & extract, multiple transforms
        ),
        ),
    ],
)
def test_run_with_plot(inpath, tname, outpath, outfig, datadir):
    dg, tab = dgpost.run(inpath)

error

/home/rafal/test/tmp_folder/F_NAME_19859640196357090399250.py:3:5: PT006 Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`
Found 1 error.

error: Fix introduced a syntax error in `/home/rafal/test/tmp_folder/F_NAME_19859640196357090399250.py` with rule codes PT006: invalid syntax. Got unexpected token ',' at byte offset 47
---
import pytest
@pytest.mark.parametrize(
    (),,
)
def test_run_with_plot(inpath, tname, outpath, outfig, datadir):
    dg, tab = dgpost.run(inpath)
---

@qarmin
Copy link
Author

qarmin commented Sep 29, 2023

Ruff 0.0.291 (latest changes from main branch)

ruff  *.py --select RUF010 --no-cache --fix --preview

file content:

def qikprop_as_a_service(filepaths: Union[str, Path, List[Union[str, Path]]],
                         ):
        raise ValueError(f"Length of output_tar_names does not equal length of globed input files:\n"
                         f"Output Files: {str(output_tar_name for output_tar_name in output_tar_names)}")

error

/home/rafal/test/tmp_folder/F_NAME_169535865006683847245904.py:4:43: RUF010 Use explicit conversion flag
Found 1 error.

error: Fix introduced a syntax error in `/home/rafal/test/tmp_folder/F_NAME_169535865006683847245904.py` with rule codes RUF010: invalid syntax. Got unexpected token 'for' at byte offset 266
---
def qikprop_as_a_service(filepaths: Union[str, Path, List[Union[str, Path]]],
                         ):
        raise ValueError(f"Length of output_tar_names does not equal length of globed input files:\n"
                         f"Output Files: {output_tar_name for output_tar_name in output_tar_names!s}")
---

charliermarsh added a commit that referenced this issue Sep 29, 2023
## Summary

This wasn't necessary in the past, since we _only_ applied this rule to
bodies that contained two statements, one of which was a `pass`. Now
that it applies to any `pass` in a block with multiple statements, we
can run into situations in which we remove both passes, and so need to
apply the fixes in isolation.

See:
#7455 (comment).
@qarmin
Copy link
Author

qarmin commented Oct 1, 2023

Ruff 0.0.291 (latest changes from main branch)

ruff  *.py --select ANN001,PLE2512 --no-cache --fix --preview

file content:

f"""#!/usr/bin/env python3
BASE_CMD = {cmd}
}}
    cmdwra�.main(ROUTING, OASE_CMD)
"""

error

/home/rafal/test/tmp_folder/F_NAME_2715173009665357364.py:4:10: PLE2512 Invalid unescaped character SUB, use "\x1A" instead
Found 1 error.

error: Fix introduced a syntax error in `/home/rafal/test/tmp_folder/F_NAME_2715173009665357364.py` with rule codes PLE2512: Got unexpected unicode at byte offset 58
---
f"""#!/usr/bin/env python3
BASE_CMD = {cmd}
}}
    cmdwr\x1\x1A�.main(ROUTING, OASE_CMD)
"""
---

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Oct 1, 2023

Ruff 0.0.291 (latest changes from main branch)

ruff  *.py --select ARG001,PLE2513 --no-cache --fix --preview

file content:

def _set_block_container_style(
):
        st.mardown(
            f"""
        }}
     .element-container div:nth-child(1� {{
            color: {COLR};
    """,
        )

error

/home/rafal/test/tmp_folder/F_NAME_9585623491027526231.py:6:39: PLE2513 Invalid unescaped character ESC, use "\x1B" instead
Found 1 error.

error: Fix introduced a syntax error in `/home/rafal/test/tmp_folder/F_NAME_9585623491027526231.py` with rule codes PLE2513: Got unexpected unicode at byte offset 123
---
def _set_block_container_style(
):
        st.mardown(
            f"""
        }}
     .element-container div:nth-child(\x1\x1B� {{
            color: {COLR};
    """,
        )
---

python_compressed.zip

konstin added a commit that referenced this issue Oct 1, 2023
**Summary** The `value` of the `FStringMiddle` for `f"""}}a�b"""` is `}a�b`, i.e. the curly brace escaping is decoded. If we iterate over string this gives us false indices causing exploding fixes for PLE251 rules (PLE2510, PLE2512, PLE2513, PLE2514, PLE2515). Instead, we now use the source range.

Handles #7455 (comment)
Handles #7455 (comment)

**Test Plan** Minimized fuzzing cases as fixtures.
konstin added a commit that referenced this issue Oct 1, 2023
**Summary** The `value` of the `FStringMiddle` for `f"""}}a�b"""` is `}a�b`, i.e. the curly brace escaping is decoded. If we iterate over string this gives us false indices causing exploding fixes for PLE251 rules (PLE2510, PLE2512, PLE2513, PLE2514, PLE2515). Instead, we now use the source range.

Handles #7455 (comment)
Handles #7455 (comment)

**Test Plan** Minimized fuzzing cases as fixtures.
konstin added a commit that referenced this issue Oct 2, 2023
**Summary** The `value` of the `FStringMiddle` for `f"""}}a�b"""` is
`}a�b`, i.e. the curly brace escaping is decoded. If we iterate over
string this gives us false indices causing exploding fixes for PLE251
rules (PLE2510, PLE2512, PLE2513, PLE2514, PLE2515). Instead, we now use
the source range.

Handles
#7455 (comment)
Handles
#7455 (comment)

**Test Plan** Minimized fuzzing cases as fixtures.
@qarmin
Copy link
Author

qarmin commented Oct 2, 2023

Ruff 0.0.292 (latest changes from main branch)

ruff  *.py --select B002,ERA001 --no-cache --fix --preview

file content:

def get_supported_sites(scraper_classes: list) -> list:
        site_info = f"{description}\n" \
                    # f"--example url: {url}"
        all_sites.append(site_info)

error

/home/rafal/test/tmp_folder/F_NAME_17511717847310148370.py:3:21: ERA001 Found commented-out code
Found 1 error.

error: Fix introduced a syntax error in `/home/rafal/test/tmp_folder/F_NAME_17511717847310148370.py` with rule codes ERA001: invalid syntax. Got unexpected token 'all_sites' at byte offset 105
---
def get_supported_sites(scraper_classes: list) -> list:
        site_info = f"{description}\n" \
        all_sites.append(site_info)
---

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Oct 2, 2023

Ruff 0.0.292 (latest changes from main branch)

ruff  *.py --select C406 --no-cache --fix --preview

file content:

picture_hashes = dict \
    (( (( ( '3d', dict
            ,  ('5.15.0', [ '0d77bf5fab130b50b52f6e08b294fb44319b002c'
                          ]
            ))
            ,  ('5.15.0', [ '06f2207b0eed942368bc5f2f5f88cb418da0b151'
                          ]
       ,  ( 'basic_output_plotly', dict
            (( ('5.4.0',  'f28fff3f214477c51c136afaf04b027cc0082bdc')
            ,  ('5.15.0', [ 'f28fff3f214477c51c136afaf04b027cc0082bdc'
                          ]
            ))
            ))
            ))
            ,  ('5.15.0', [ '92118fc5f98e118ff29cab3ed947c701eed92a6d'
                          ]
            ))
       ))

error

/home/rafal/test/tmp_folder/F_NAME_8746074058484126729.py:6:36: C406 Unnecessary `tuple` literal (rewrite as a `dict` literal)
Found 2 errors (1 fixed, 1 remaining).

error: Failed to create fix for UnnecessaryLiteralDict: Failed to extract expression from source
error: Failed to create fix for UnnecessaryLiteralDict: Failed to extract expression from source

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Oct 2, 2023

Ruff 0.0.292 (latest changes from main branch)

ruff  *.py --select EM101 --no-cache --fix --preview

file content:

def unvectorize_ld_matrix(vec):
    if mat_size * (mat_size + 1) / 2 != vec.size: \
        raise ValueError('Vector is an impossible size')

error

/home/rafal/test/tmp_folder/F_NAME_6002756774573705671.py:3:26: EM101 Exception must not use a string literal, assign to variable first
Found 1 error.

error: Fix introduced a syntax error in `/home/rafal/test/tmp_folder/F_NAME_6002756774573705671.py` with rule codes EM101: unexpected indent at byte offset 129
---
def unvectorize_ld_matrix(vec):
    if mat_size * (mat_size + 1) / 2 != vec.size: \
        msg = 'Vector is an impossible size'
        raise ValueError(msg)
---

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Oct 2, 2023

Ruff 0.0.292 (latest changes from main branch)

ruff  *.py --select FURB140 --no-cache --fix --preview

file content:

from future.builtins import list, range, str, zip
def _parseparam(s):
        return [self.policy.header_fetch_parse(k, v)
                for k, v in self._headers]

error

/home/rafal/test/tmp_folder/F_NAME_12108810957222076977.py:3:16: FURB140 Use `itertools.starmap` instead of the generator
Found 1 error.

error: Failed to create fix for ReimplementedStarmap: Can't use built-in `list` constructor

python_compressed.zip

@charliermarsh
Copy link
Member

That last one is "working as intended", but it's not a useful user-facing message.

@qarmin
Copy link
Author

qarmin commented Oct 3, 2023

Ruff 0.0.292 (latest changes from main branch)

ruff  *.py --select PT006 --no-cache --fix --preview

file content:

import pytest
@pytest.mark.parametrize(
    [
        (  # ts1 - load 2 dgs, extract 2 tables with interpolation
        (  # ts3 - load & extract, multiple transforms
        ),
        ),
    ],
)
def test_run_with_plot(inpath, tname, outpath, outfig, datadir):
    dg, tab = dgpost.run(inpath)

error

/home/rafal/test/tmp_folder/F_NAME_15771089586878863891.py:3:5: PT006 Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv`
Found 1 error.

error: Fix introduced a syntax error in `/home/rafal/test/tmp_folder/F_NAME_15771089586878863891.py` with rule codes PT006: invalid syntax. Got unexpected token ',' at byte offset 47
---
import pytest
@pytest.mark.parametrize(
    (),,
)
def test_run_with_plot(inpath, tname, outpath, outfig, datadir):
    dg, tab = dgpost.run(inpath)
---

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Oct 3, 2023

Ruff 0.0.292 (latest changes from main branch)

ruff  *.py --select PT014 --no-cache --fix --preview

file content:

import pytest
def test_platforms(platform):
        raise Exception("bad testing type value: {}".format(platform.platform["api"]))
@pytest.mark.parametrize('data', [from_zero_to_hero, from_zero_to_hero], ids=unique_id.id)  # get test data layer x2
def test_all_threads_are_done():
    import threading

error

/home/rafal/test/tmp_folder/F_NAME_358795462047586145.py:4:54: PT014 Duplicate of test case at index 0 in `@pytest_mark.parametrize`
Found 1 error.

error: Fix introduced a syntax error in `/home/rafal/test/tmp_folder/F_NAME_358795462047586145.py` with rule codes PT014: invalid syntax. Got unexpected token '=' at byte offset 187
---
import pytest
def test_platforms(platform):
        raise Exception("bad testing type value: {}".format(platform.platform["api"]))
@pytest.mark.parametrize('data', [from_zero_to_hero, ids=unique_id.id)  # get test data layer x2
def test_all_threads_are_done():
    import threading
---

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Oct 3, 2023

Ruff 0.0.292 (latest changes from main branch)

ruff  *.py --select RUF010 --no-cache --fix --preview

file content:

def qikprop_as_a_service(filepaths: Union[str, Path, List[Union[str, Path]]],
                         ):
        raise ValueError(f"Length of output_tar_names does not equal length of globed input files:\n"
                         f"Output Files: {str(output_tar_name for output_tar_name in output_tar_names)}")

error

/home/rafal/test/tmp_folder/F_NAME_5035183614041402624.py:4:43: RUF010 Use explicit conversion flag
Found 1 error.

error: Fix introduced a syntax error in `/home/rafal/test/tmp_folder/F_NAME_5035183614041402624.py` with rule codes RUF010: invalid syntax. Got unexpected token 'for' at byte offset 266
---
def qikprop_as_a_service(filepaths: Union[str, Path, List[Union[str, Path]]],
                         ):
        raise ValueError(f"Length of output_tar_names does not equal length of globed input files:\n"
                         f"Output Files: {output_tar_name for output_tar_name in output_tar_names!s}")
---

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Oct 3, 2023

Ruff 0.0.292 (latest changes from main branch)

ruff  *.py --select RUF013 --no-cache --fix --preview

file content:

if TYPE_CHECKING:
    from typing_extensions import Literal

    def __init__(
        self,
        *,
        name: str,
        log: str,
        outcome: "Literal['passed', 'failed', 'skipped']" = None,
        status: "Literal['PASS', 'FAIL', 'TODO']" = None,
    ):
        self.log = log

error

/home/rafal/test/tmp_folder/F_NAME_4663957540923056968.py:9:19: RUF013 PEP 484 prohibits implicit `Optional`
/home/rafal/test/tmp_folder/F_NAME_4663957540923056968.py:10:18: RUF013 PEP 484 prohibits implicit `Optional`
Found 2 errors.

error: Fix introduced a syntax error in `/home/rafal/test/tmp_folder/F_NAME_4663957540923056968.py` with rule codes RUF013: invalid syntax. Got unexpected token 'passed' at byte offset 205
---
from typing import Optional
if TYPE_CHECKING:
    from typing_extensions import Literal

    def __init__(
        self,
        *,
        name: str,
        log: str,
        outcome: "Optional[Literal["passed", "failed", "skipped"]]" = None,
        status: "Optional[Literal["PASS", "FAIL", "TODO"]]" = None,
    ):
        self.log = log

---

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Oct 3, 2023

Ruff 0.0.292 (latest changes from main branch)

ruff  *.py --select RET503,SIM108 --no-cache --fix --preview

file content:

def extract(o, index):
        return o
        if isinstance(index, int):
             index=index+1
        else:
             index = [x+1 for x in index]  

error

/home/rafal/test/tmp_folder/F_NAME_15788764829505208504.py:3:9: SIM108 Use ternary operator `index = index + 1 if isinstance(index, int) else [x + 1 for x in index]` instead of `if`-`else`-block
/home/rafal/test/tmp_folder/F_NAME_15788764829505208504.py:4:14: RET503 Missing explicit `return` at the end of function able to return non-`None` value
/home/rafal/test/tmp_folder/F_NAME_15788764829505208504.py:6:14: RET503 Missing explicit `return` at the end of function able to return non-`None` value
Found 3 errors.

error: Fix introduced a syntax error in `/home/rafal/test/tmp_folder/F_NAME_15788764829505208504.py` with rule codes RET503, SIM108: unexpected indent at byte offset 122
---
def extract(o, index):
        return o
        index = index + 1 if isinstance(index, int) else [x + 1 for x in index]  
             return None
---

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Oct 30, 2023

(latest changes from main branch)

ruff  *.py --select ANN002,E274 --no-cache --fix --preview

file content:

class PIPoint(object):
	swagger_types = {
	}
	def id(self):
		return self._id

error

/home/rafal/test/tmp_folder/F_NAME_9896153931138493637.py:5:1: E274 Tab before keyword
Found 1 error.
[*] 1 fixable with the `--fix` option.

error: Fix introduced a syntax error in `/home/rafal/test/tmp_folder/F_NAME_9896153931138493637.py` with rule codes E274: unindent does not match any outer indentation level at byte offset 61
---
class PIPoint(object):
	swagger_types = {
	}
	def id(self):
 return self._id
---

python_compressed.zip

@qarmin
Copy link
Author

qarmin commented Jan 30, 2024

Most of the problems that occur in the regular code have been fixed, and the rest, are usually variations of not very correct code.

So now I'll try to add to #8402 the errors that occur in the regular code

@qarmin qarmin closed this as completed Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fuzzer Surfaced via fuzzing.
Projects
None yet
Development

No branches or pull requests

3 participants