Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/sre_engine/generate_tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
import os
from pathlib import Path
import re
import json
from itertools import chain
from pathlib import Path

m = re.search(r"const SRE_MAGIC: usize = (\d+);", open("src/constants.rs").read())
sre_engine_magic = int(m.group(1))
Expand Down
4 changes: 2 additions & 2 deletions crawl_sourcecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"""

import ast
import sys
import symtable
import dis
import symtable
import sys

filename = sys.argv[1]
print("Crawling file:", filename)
Expand Down
13 changes: 7 additions & 6 deletions extra_tests/custom_text_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@
# SOFTWARE.


import unittest
import os, sys, traceback
import inspect
import json
import time
import re
import operator
from unittest.runner import result
from unittest.runner import registerResult
import os
import re
import sys
import time
import traceback
import unittest
from functools import reduce
from unittest.runner import registerResult, result


class TablePrinter(object):
Expand Down
4 changes: 2 additions & 2 deletions extra_tests/jsontests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import unittest

from custom_text_test_runner import CustomTextTestRunner as Runner
from test.libregrtest.runtest import findtests
import os


testnames = findtests()
# idk why this fixes the hanging, if it does
Expand Down
3 changes: 1 addition & 2 deletions extra_tests/snippets/builtin_all.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from testutils import assert_raises
from testutils import TestFailingBool, TestFailingIter
from testutils import TestFailingBool, TestFailingIter, assert_raises

assert all([True])
assert not all([False])
Expand Down
3 changes: 1 addition & 2 deletions extra_tests/snippets/builtin_any.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from testutils import assert_raises
from testutils import TestFailingBool, TestFailingIter
from testutils import TestFailingBool, TestFailingIter, assert_raises

assert any([True])
assert not any([False])
Expand Down
3 changes: 2 additions & 1 deletion extra_tests/snippets/builtin_bytearray.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from testutils import assert_raises
import pickle
import sys

from testutils import assert_raises

# new
assert bytearray([1, 2, 3])
assert bytearray((1, 2, 3))
Expand Down
2 changes: 1 addition & 1 deletion extra_tests/snippets/builtin_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import builtins
import platform
import pickle
import platform
import sys


Expand Down
2 changes: 1 addition & 1 deletion extra_tests/snippets/builtin_pow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from testutils import assert_raises, assert_equal
from testutils import assert_equal, assert_raises

assert pow(3, 2) == 9
assert pow(5, 3, 100) == 25
Expand Down
3 changes: 2 additions & 1 deletion extra_tests/snippets/builtin_print.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from testutils import assert_raises
import io

from testutils import assert_raises

print(2 + 3)

assert_raises(TypeError, print, "test", end=4, _msg="wrong type passed to end")
Expand Down
2 changes: 1 addition & 1 deletion extra_tests/snippets/builtin_str.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from testutils import assert_raises, AssertRaises, skip_if_unsupported
from testutils import AssertRaises, assert_raises, skip_if_unsupported

assert "".__eq__(1) == NotImplemented
assert "a" == "a"
Expand Down
2 changes: 1 addition & 1 deletion extra_tests/snippets/dir_module/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .relative import value
from .dir_module_inner import value2
from .relative import value
Comment on lines 1 to +2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix lint blocker (F401): mark re-exported import as intentional (or export via __all__).
Flake8 reports Line 2 as unused; if this is a package re-export, annotate it to avoid CI lint failures.

Based on learnings, use ruff for linting Python code.

 from .dir_module_inner import value2
-from .relative import value
+from .relative import value  # noqa: F401
+
+__all__ = ["value", "value2"]
🧰 Tools
🪛 Flake8 (7.3.0)

[error] 1-1: '.dir_module_inner.value2' imported but unused

(F401)


[error] 2-2: '.relative.value' imported but unused

(F401)

🤖 Prompt for AI Agents
extra_tests/snippets/dir_module/__init__.py lines 1-2: Flake8/ruff flags the
import on line 2 as unused (F401) because it's a package re-export; either mark
the re-export as intentional by appending a noqa for F401 to the import
statement or explicitly export the names via an __all__ list. Fix by choosing
one: 1) add the comment "# noqa: F401" to the import of value to silence the
unused-import lint, or 2) add an __all__ = ["value", "value2"] (and keep the
imports) so the module explicitly exports these symbols for re-export.

13 changes: 7 additions & 6 deletions extra_tests/snippets/forbidden_instantiation.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
from typing import Type
from types import (
GeneratorType,
CoroutineType,
AsyncGeneratorType,
BuiltinFunctionType,
BuiltinMethodType,
WrapperDescriptorType,
MethodWrapperType,
MethodDescriptorType,
ClassMethodDescriptorType,
CoroutineType,
FrameType,
GeneratorType,
GetSetDescriptorType,
MemberDescriptorType,
MethodDescriptorType,
MethodWrapperType,
WrapperDescriptorType,
)
from typing import Type

from testutils import assert_raises


Expand Down
11 changes: 6 additions & 5 deletions extra_tests/snippets/import.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import import_target, import_target as aliased
from import_target import func, other_func
from import_target import func as aliased_func, other_func as aliased_other_func
from import_star import *

import import_mutual1
import import_target
import import_target as aliased
from import_star import *
from import_target import func, other_func
from import_target import func as aliased_func
from import_target import other_func as aliased_other_func

assert import_target.X == import_target.func()
assert import_target.X == func()
Expand Down
3 changes: 2 additions & 1 deletion extra_tests/snippets/protocol_index_bad.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Test that indexing ops don't hang when an object with a mutating
__index__ is used."""

from testutils import assert_raises
from array import array

from testutils import assert_raises


class BadIndex:
def __index__(self):
Expand Down
3 changes: 2 additions & 1 deletion extra_tests/snippets/stdlib_array.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from testutils import assert_raises
from array import array
from pickle import dumps, loads

from testutils import assert_raises

a1 = array("b", [0, 1, 2, 3])

assert a1.tobytes() == b"\x00\x01\x02\x03"
Expand Down
2 changes: 1 addition & 1 deletion extra_tests/snippets/stdlib_binascii.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import binascii
from testutils import assert_raises, assert_equal

from testutils import assert_equal, assert_raises

# hexlify tests
h = binascii.hexlify
Expand Down
1 change: 0 additions & 1 deletion extra_tests/snippets/stdlib_collections.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections import deque


d = deque([0, 1, 2])

d.append(1)
Expand Down
3 changes: 2 additions & 1 deletion extra_tests/snippets/stdlib_collections_deque.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from testutils import assert_raises
from collections import deque
from typing import Deque

from testutils import assert_raises


def test_deque_iterator__new__():
klass = type(iter(deque()))
Expand Down
4 changes: 2 additions & 2 deletions extra_tests/snippets/stdlib_csv.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from testutils import assert_raises

import csv

from testutils import assert_raises

for row in csv.reader(["one,two,three"]):
[one, two, three] = row
assert one == "one"
Expand Down
18 changes: 10 additions & 8 deletions extra_tests/snippets/stdlib_ctypes.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import os as _os, sys as _sys
import os as _os
import sys as _sys
import types as _types

from _ctypes import RTLD_LOCAL, RTLD_GLOBAL
from _ctypes import sizeof
from _ctypes import _SimpleCData, Array
from _ctypes import RTLD_GLOBAL, RTLD_LOCAL, Array, _SimpleCData, sizeof
from _ctypes import CFuncPtr as _CFuncPtr

from struct import calcsize as _calcsize


assert Array.__class__.__name__ == "PyCArrayType"
assert Array.__base__.__name__ == "_CData"

Expand All @@ -24,8 +20,14 @@

from _ctypes import (
FUNCFLAG_CDECL as _FUNCFLAG_CDECL,
)
from _ctypes import (
FUNCFLAG_PYTHONAPI as _FUNCFLAG_PYTHONAPI,
)
from _ctypes import (
FUNCFLAG_USE_ERRNO as _FUNCFLAG_USE_ERRNO,
)
from _ctypes import (
FUNCFLAG_USE_LASTERROR as _FUNCFLAG_USE_LASTERROR,
)

Expand Down Expand Up @@ -210,8 +212,8 @@ class c_bool(_SimpleCData):
assert abs(f.value - 3.14) < 1e-06

if _os.name == "nt":
from _ctypes import LoadLibrary as _dlopen
from _ctypes import FUNCFLAG_STDCALL as _FUNCFLAG_STDCALL
from _ctypes import LoadLibrary as _dlopen
elif _os.name == "posix":
from _ctypes import dlopen as _dlopen

Expand Down
21 changes: 7 additions & 14 deletions extra_tests/snippets/stdlib_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,20 @@
"""

# import copy
import sys
import random

from operator import lt, le, gt, ge, eq, ne, truediv, floordiv, mod

import datetime as datetime_module
from datetime import MINYEAR, MAXYEAR
from datetime import timedelta
from datetime import tzinfo
from datetime import time
from datetime import timezone
from datetime import date, datetime
import random
import sys
import time as _time
from datetime import MAXYEAR, MINYEAR, date, datetime, time, timedelta, timezone, tzinfo
from operator import eq, floordiv, ge, gt, le, lt, mod, ne, truediv

from testutils import (
assert_raises,
assert_equal,
assert_true,
assert_false,
assert_isinstance,
assert_in,
assert_isinstance,
assert_raises,
assert_true,
)

# An arbitrary collection of objects of non-datetime types, for testing
Expand Down
3 changes: 1 addition & 2 deletions extra_tests/snippets/stdlib_dir_module.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from testutils import assert_equal

import dir_module
from testutils import assert_equal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove unused import.

The assert_equal import is not used anywhere in this file, as correctly identified by Flake8.

Apply this diff to remove the unused import:

-from testutils import assert_equal
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from testutils import assert_equal
🧰 Tools
🪛 Flake8 (7.3.0)

[error] 2-2: 'testutils.assert_equal' imported but unused

(F401)

🤖 Prompt for AI Agents
In extra_tests/snippets/stdlib_dir_module.py around line 2, the file imports
assert_equal from testutils but that symbol is unused; remove the unused import
line so the file no longer imports assert_equal (delete or comment out the "from
testutils import assert_equal" line) to satisfy Flake8.


assert dir_module.value == 5
assert dir_module.value2 == 7
Expand Down
1 change: 1 addition & 0 deletions extra_tests/snippets/stdlib_functools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from functools import reduce

from testutils import assert_raises


Expand Down
3 changes: 2 additions & 1 deletion extra_tests/snippets/stdlib_io.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from io import BufferedReader, FileIO, StringIO, BytesIO
import os
from io import BufferedReader, BytesIO, FileIO, StringIO

from testutils import assert_raises

fi = FileIO("README.md")
Expand Down
3 changes: 1 addition & 2 deletions extra_tests/snippets/stdlib_itertools.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import itertools
import pickle

from testutils import assert_raises

import pickle

# itertools.chain tests
chain = itertools.chain

Expand Down
5 changes: 3 additions & 2 deletions extra_tests/snippets/stdlib_json.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from testutils import assert_raises
import json
from io import StringIO, BytesIO
from io import BytesIO, StringIO

from testutils import assert_raises


def round_trip_test(obj):
Expand Down
2 changes: 1 addition & 1 deletion extra_tests/snippets/stdlib_marshal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
import marshal
import unittest


class MarshalTests(unittest.TestCase):
Expand Down
1 change: 1 addition & 0 deletions extra_tests/snippets/stdlib_math.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import math

from testutils import assert_raises, skip_if_unsupported

NAN = float("nan")
Expand Down
2 changes: 1 addition & 1 deletion extra_tests/snippets/stdlib_os.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import time
import stat
import sys
import time

from testutils import assert_raises

Expand Down
3 changes: 2 additions & 1 deletion extra_tests/snippets/stdlib_pwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
if sys.platform.startswith("win"):
exit(0)

from testutils import assert_raises
import pwd

from testutils import assert_raises

with assert_raises(KeyError):
fake_name = "fake_user"
while pwd.getpwnam(fake_name):
Expand Down
6 changes: 3 additions & 3 deletions extra_tests/snippets/stdlib_select.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from testutils import assert_raises

import select
import sys
import socket
import sys

from testutils import assert_raises


class Nope:
Expand Down
3 changes: 2 additions & 1 deletion extra_tests/snippets/stdlib_signal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import signal
import time
import sys
import time

from testutils import assert_raises

assert_raises(TypeError, lambda: signal.signal(signal.SIGINT, 2))
Expand Down
3 changes: 2 additions & 1 deletion extra_tests/snippets/stdlib_socket.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _socket
import socket
import os
import socket

from testutils import assert_raises

assert _socket.socket == _socket.SocketType
Expand Down
Loading
Loading