chore: apply ruff's pyupgrade linter rules to modernize Python code with targeted version (#2419)

This commit is contained in:
Bowen Liang
2024-02-09 15:21:33 +08:00
committed by GitHub
parent 589099a005
commit 063191889d
246 changed files with 912 additions and 937 deletions

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Cipher/PKCS1_OAEP.py : PKCS#1 OAEP
#

View File

@@ -1,4 +1,3 @@
# -*- coding:utf-8 -*-
import random
import re
import string
@@ -57,7 +56,7 @@ def timestamp_value(timestamp):
raise ValueError(error)
class str_len(object):
class str_len:
""" Restrict input to an integer in a range (inclusive) """
def __init__(self, max_length, argument='argument'):
@@ -74,7 +73,7 @@ class str_len(object):
return value
class float_range(object):
class float_range:
""" Restrict input to an float in a range (inclusive) """
def __init__(self, low, high, argument='argument'):
self.low = low
@@ -91,7 +90,7 @@ class float_range(object):
return value
class datetime_string(object):
class datetime_string:
def __init__(self, format, argument='argument'):
self.format = format
self.argument = argument
@@ -111,7 +110,7 @@ def _get_float(value):
try:
return float(value)
except (TypeError, ValueError):
raise ValueError('{0} is not a valid float'.format(value))
raise ValueError('{} is not a valid float'.format(value))
def timezone(timezone_string):
if timezone_string and timezone_string in available_timezones():

View File

@@ -1,4 +1,3 @@
# -*- coding:utf-8 -*-
class InfiniteScrollPagination:
def __init__(self, data, limit, has_more):

View File

@@ -1,5 +1,4 @@
import json
from typing import List
from langchain.schema import OutputParserException
@@ -30,7 +29,7 @@ def parse_json_markdown(json_string: str) -> dict:
return parsed
def parse_and_check_json_markdown(text: str, expected_keys: List[str]) -> dict:
def parse_and_check_json_markdown(text: str, expected_keys: list[str]) -> dict:
try:
json_obj = parse_json_markdown(text)
except json.JSONDecodeError as e:

View File

@@ -1,4 +1,3 @@
# -*- coding:utf-8 -*-
import jwt
from flask import current_app
from werkzeug.exceptions import Unauthorized

View File

@@ -1,4 +1,3 @@
# -*- coding:utf-8 -*-
import base64
import binascii
import hashlib

View File

@@ -1,4 +1,3 @@
# -*- coding:utf-8 -*-
import hashlib
from Crypto.Cipher import AES