Ruff auto-format (#6422)

This commit is contained in:
Shahar Naveh authored and GitHub committed 2025-12-12 22:46:39 +09:00
1 parent 093ba251ab
commit 9ccf4c1872
48 files changed
+120 -115

No files matched your search

+3 -3
View File
@@ -1,8 +1,8 @@
import os
from pathlib import Path
import re
import json
import os
import re
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))
+2 -2
View File
@@ -9,9 +9,9 @@ $ diff cpython.txt rustpython.txt
"""
import ast
import sys
import symtable
import dis
import symtable
import sys
filename = sys.argv[1]
print("Crawling file:", filename)
+7 -6
View File
@@ -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):
+2 -2
View File
@@ -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
+1 -2
View File
@@ -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])
+1 -2
View File
@@ -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])
+2 -1
View File
@@ -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))
+1 -1
View File
@@ -1,6 +1,6 @@
import builtins
import platform
import pickle
import platform
import sys
+1 -1
View File
@@ -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
+2 -1
View File
@@ -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")
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -1,2 +1,2 @@
from .relative import value
from .dir_module_inner import value2
from .relative import value
@@ -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
+6 -5
View File
@@ -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()
+2 -1
View File
@@ -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):
+2 -1
View File
@@ -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"
+1 -1
View File
@@ -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
@@ -1,6 +1,5 @@
from collections import deque
d = deque([0, 1, 2])
d.append(1)
@@ -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()))
+2 -2
View File
@@ -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"
+10 -8
View File
@@ -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"
@@ -24,8 +20,14 @@ if _os.name == "posix" and _sys.platform == "darwin":
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,
)
@@ -210,8 +212,8 @@ assert i.value == 42
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
+7 -14
View File
@@ -4,27 +4,20 @@ See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases
"""
# 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
+1 -2
View File
@@ -1,6 +1,5 @@
from testutils import assert_equal
import dir_module
from testutils import assert_equal
assert dir_module.value == 5
assert dir_module.value2 == 7
+1
View File
@@ -1,4 +1,5 @@
from functools import reduce
from testutils import assert_raises
+2 -1
View File
@@ -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")
+1 -2
View File
@@ -1,9 +1,8 @@
import itertools
import pickle
from testutils import assert_raises
import pickle
# itertools.chain tests
chain = itertools.chain
+3 -2
View File
@@ -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):
+1 -1
View File
@@ -1,5 +1,5 @@
import unittest
import marshal
import unittest
class MarshalTests(unittest.TestCase):
+1
View File
@@ -1,4 +1,5 @@
import math
from testutils import assert_raises, skip_if_unsupported
NAN = float("nan")
+1 -1
View File
@@ -1,7 +1,7 @@
import os
import time
import stat
import sys
import time
from testutils import assert_raises
+2 -1
View File
@@ -4,9 +4,10 @@ import sys
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):
+3 -3
View File
@@ -1,8 +1,8 @@
from testutils import assert_raises
import select
import sys
import socket
import sys
from testutils import assert_raises
class Nope:
+2 -1
View File
@@ -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))
+2 -1
View File
@@ -1,6 +1,7 @@
import _socket
import socket
import os
import socket
from testutils import assert_raises
assert _socket.socket == _socket.SocketType
-1
View File
@@ -1,6 +1,5 @@
import string
assert string.ascii_letters == "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
assert string.ascii_lowercase == "abcdefghijklmnopqrstuvwxyz"
assert string.ascii_uppercase == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+2 -1
View File
@@ -1,6 +1,7 @@
from testutils import assert_raises
import struct
from testutils import assert_raises
data = struct.pack("IH", 14, 12)
assert data == bytes([14, 0, 0, 0, 12, 0])
+3 -3
View File
@@ -1,7 +1,7 @@
import subprocess
import time
import sys
import signal
import subprocess
import sys
import time
from testutils import assert_raises
+1 -1
View File
@@ -1,6 +1,6 @@
import sys
import os
import subprocess
import sys
from testutils import assert_raises
+2 -1
View File
@@ -1,4 +1,5 @@
from _weakref import ref, proxy
from _weakref import proxy, ref
from testutils import assert_raises
+1
View File
@@ -1,4 +1,5 @@
import zlib
from testutils import assert_raises
# checksum functions
+6 -6
View File
@@ -2,14 +2,14 @@
# in the snippets folder.
import sys
import os
import unittest
import glob
import logging
import subprocess
import contextlib
import enum
import glob
import logging
import os
import subprocess
import sys
import unittest
from pathlib import Path
+1 -1
View File
@@ -7,8 +7,8 @@ import argparse
import dataclasses
import difflib
import pathlib
from typing import Optional
import warnings
from typing import Optional
import requests
from jinja2 import Environment, FileSystemLoader
-1
View File
@@ -19,7 +19,6 @@ import os
import re
import sys
parser = argparse.ArgumentParser(
description="Generate ssl_data.rs from OpenSSL sources"
)
+1 -1
View File
@@ -1,5 +1,5 @@
import browser
import asyncweb
import browser
async def main(delay):
+1 -2
View File
@@ -2,7 +2,6 @@
# available as os.path as well as a few other utilities, but will raise an
# OSError for anything that actually requires an OS
import _dummy_os
import asyncweb
import whlimport
@@ -13,8 +12,8 @@ whlimport.setup()
async def main():
await whlimport.load_package("pygments")
import pygments
import pygments.lexers
import pygments.formatters.html
import pygments.lexers
lexer = pygments.lexers.get_lexer_by_name("python")
fmter = pygments.formatters.html.HtmlFormatter(noclasses=True, style="default")
+1 -1
View File
@@ -1,4 +1,4 @@
from browser import fetch, alert
from browser import alert, fetch
def fetch_handler(repos):
+10 -9
View File
@@ -1,10 +1,11 @@
import subprocess
import os
import time
import socket
import atexit
import pytest
import os
import socket
import subprocess
import sys
import time
import pytest
PORT = 8080
@@ -65,11 +66,11 @@ def wait_for_port(port, host="localhost", timeout=5.0):
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import JavascriptException
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
class Driver(webdriver.Firefox):
+8 -9
View File
@@ -17,15 +17,14 @@
# We then run this second generated script with RustPython.
import argparse
import re
import os
import re
import sys
import json
import warnings
import inspect
import subprocess
import json
import os
import platform
import re
import subprocess
import sys
import warnings
from pydoc import ModuleScanner
if not sys.flags.isolated:
@@ -327,13 +326,13 @@ libdir = ""
def compare():
import inspect
import io
import json
import os
import platform
import re
import sys
import warnings
from contextlib import redirect_stdout
import json
import platform
def method_incompatibility_reason(typ, method_name, real_method_value):
has_method = hasattr(typ, method_name)