chore(pre-commit): Add pyupgrade and pycln hooks (#24197)

This commit is contained in:
John Bodley
2023-06-01 12:01:10 -07:00
committed by GitHub
parent 7d7ce63970
commit a4d5d7c6b9
448 changed files with 3084 additions and 3305 deletions

View File

@@ -43,13 +43,13 @@ def test_escape_value():
assert result == "'=value"
result = csv.escape_value("|value")
assert result == "'\|value"
assert result == r"'\|value"
result = csv.escape_value("%value")
assert result == "'%value"
result = csv.escape_value("=cmd|' /C calc'!A0")
assert result == "'=cmd\|' /C calc'!A0"
assert result == r"'=cmd\|' /C calc'!A0"
result = csv.escape_value('""=10+2')
assert result == '\'""=10+2'
@@ -74,7 +74,7 @@ def test_df_to_escaped_csv():
assert escaped_csv_rows == [
["col_a", "'=func()"],
["-10", "'=cmd\|' /C calc'!A0"],
["-10", r"'=cmd\|' /C calc'!A0"],
["a", "'=b"], # pandas seems to be removing the leading ""
["' =a", "b"],
]

View File

@@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from typing import Any, Dict, List, Optional
from typing import Any, Optional
from sqlalchemy import String, TypeDecorator
from sqlalchemy_utils import EncryptedType
@@ -28,9 +28,9 @@ from tests.integration_tests.base_tests import SupersetTestCase
class CustomEncFieldAdapter(AbstractEncryptedFieldAdapter):
def create(
self,
app_config: Optional[Dict[str, Any]],
*args: List[Any],
**kwargs: Optional[Dict[str, Any]]
app_config: Optional[dict[str, Any]],
*args: list[Any],
**kwargs: Optional[dict[str, Any]]
) -> TypeDecorator:
if app_config:
return StringEncryptedType(*args, app_config["SECRET_KEY"], **kwargs)

View File

@@ -14,14 +14,13 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from typing import List
from flask_appbuilder import SQLA
from superset.models.dashboard import Dashboard
def get_dashboards_ids(db: SQLA, dashboard_slugs: List[str]) -> List[int]:
def get_dashboards_ids(db: SQLA, dashboard_slugs: list[str]) -> list[int]:
result = (
db.session.query(Dashboard.id).filter(Dashboard.slug.in_(dashboard_slugs)).all()
)

View File

@@ -14,7 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from typing import Any, Callable, Dict
from typing import Any, Callable
import pytest
@@ -23,7 +23,7 @@ from superset.utils.public_interfaces import compute_hash, get_warning_message
# These are public interfaces exposed by Superset. Make sure
# to only change the interfaces and update the hashes in new
# major versions of Superset.
hashes: Dict[Callable[..., Any], str] = {}
hashes: dict[Callable[..., Any], str] = {}
@pytest.mark.parametrize("interface,expected_hash", list(hashes.items()))