Skip to content
Draft
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
38 changes: 9 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,6 @@ repos:
rev: "0.50"
hooks:
- id: check-manifest
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- id: isort
name: insert future imports
args:
- -a
- from __future__ import annotations
- --append-only
files: ^src/snowflake/connector/.*\.py$
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: local
hooks:
- id: check-no-native-http
Expand All @@ -72,12 +56,6 @@ repos:
files: ^src/snowflake/connector/.*\.py$
exclude: src/snowflake/connector/options.py
args: [--show-fixes]
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.13.0'
hooks:
Expand Down Expand Up @@ -111,13 +89,6 @@ repos:
- types-setuptools
- types-pyOpenSSL
- types-setuptools
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
args:
- --safe
language_version: python3
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.3
hooks:
Expand All @@ -127,3 +98,12 @@ repos:
(?x)^(
src/snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/.*\.h|
)$
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.14.8
hooks:
# Run the linter.
- id: ruff-check
args: [ --fix ]
# Run the formatter.
- id: ruff-format
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ exclude tox.ini
exclude mypy.ini
exclude .clang-format
exclude .wiremock/*
exclude ruff.toml

prune ci
prune benchmark
Expand Down
1 change: 1 addition & 0 deletions benchmark/benchmark_unit_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from snowflake.connector.converter_snowsql import SnowflakeConverterSnowSQL


logger = getLogger(__name__)

ConverterSnowSQL = SnowflakeConverterSnowSQL
Expand Down
35 changes: 16 additions & 19 deletions ci/anaconda/validate_deps_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
import configparser
import re
import sys

from collections.abc import Iterable
from pathlib import Path
from typing import Dict, Iterable, List, Tuple

import yaml

Expand All @@ -36,7 +37,7 @@ def normalize_name(name: str) -> str:
return name.strip().lower().replace("_", "-")


def split_requirement(req: str) -> Tuple[str, str]:
def split_requirement(req: str) -> tuple[str, str]:
"""Split a requirement into name and version specifier.

Drops PEP 508 markers (after ';') and conda selectors (after '#').
Expand Down Expand Up @@ -71,7 +72,7 @@ def split_requirement(req: str) -> Tuple[str, str]:
return normalize_name(name), spec


def get_setup_install_requires(cfg_path: Path) -> List[str]:
def get_setup_install_requires(cfg_path: Path) -> list[str]:
"""Extract normalized install_requires entries from setup.cfg.

Args:
Expand All @@ -87,7 +88,7 @@ def get_setup_install_requires(cfg_path: Path) -> List[str]:
if not parser.has_option("options", "install_requires"):
raise RuntimeError(f"Missing install_requires under [options] in {cfg_path}")
raw_value = parser.get("options", "install_requires")
deps: List[str] = []
deps: list[str] = []
for line in raw_value.splitlines():
item = line.strip()
if not item or item.startswith("#"):
Expand All @@ -98,7 +99,7 @@ def get_setup_install_requires(cfg_path: Path) -> List[str]:
return deps


def get_meta_run_requirements(meta_path: Path) -> List[str]:
def get_meta_run_requirements(meta_path: Path) -> list[str]:
"""Extract normalized run requirements from meta.yaml.

Args:
Expand All @@ -108,7 +109,7 @@ def get_meta_run_requirements(meta_path: Path) -> List[str]:
List of strings in the form "<name> <spec>" where spec may be empty.
"""
text = meta_path.read_text(encoding="utf-8")
cleaned_lines: List[str] = []
cleaned_lines: list[str] = []
for line in text.splitlines():
if "{%" in line or "%}" in line:
continue
Expand All @@ -125,7 +126,7 @@ def get_meta_run_requirements(meta_path: Path) -> List[str]:
reqs = data.get("requirements", {}) or {}
run_items = reqs.get("run", []) or []

deps: List[str] = []
deps: list[str] = []
for idx, it in enumerate(run_items):
if not isinstance(it, str):
raise TypeError(
Expand All @@ -138,7 +139,7 @@ def get_meta_run_requirements(meta_path: Path) -> List[str]:
return deps


def get_setup_extra_requires(cfg_path: Path, extra: str) -> List[str]:
def get_setup_extra_requires(cfg_path: Path, extra: str) -> list[str]:
"""Extract normalized requirements for a given extra from setup.cfg.

Args:
Expand All @@ -155,11 +156,9 @@ def get_setup_extra_requires(cfg_path: Path, extra: str) -> List[str]:
raise RuntimeError(f"Missing [options.extras_require] section in {cfg_path}")
key = extra.strip().lower()
if not parser.has_option(section, key):
raise RuntimeError(
f"Missing extra '{key}' under [options.extras_require] in {cfg_path}"
)
raise RuntimeError(f"Missing extra '{key}' under [options.extras_require] in {cfg_path}")
raw_value = parser.get(section, key)
deps: List[str] = []
deps: list[str] = []
for line in raw_value.splitlines():
item = line.strip()
if not item or item.startswith("#"):
Expand All @@ -181,8 +180,8 @@ def compare_deps(setup_deps: Iterable[str], meta_deps: Iterable[str]) -> str:
Empty string if equal, otherwise a multi-line diff description.
"""

def to_map(items: Iterable[str]) -> Dict[str, str]:
mapping: Dict[str, str] = {}
def to_map(items: Iterable[str]) -> dict[str, str]:
mapping: dict[str, str] = {}
for it in items:
parts = it.split(" ", 1)
name = parts[0]
Expand All @@ -198,15 +197,15 @@ def to_map(items: Iterable[str]) -> Dict[str, str]:
missing = sorted(s_names - m_names)
extra = sorted(m_names - s_names)

mismatches: List[Tuple[str, str, str]] = []
mismatches: list[tuple[str, str, str]] = []
for name in sorted(s_names & m_names):
if s_map.get(name, "") != m_map.get(name, ""):
mismatches.append((name, s_map.get(name, ""), m_map.get(name, "")))

if not (missing or extra or mismatches):
return ""

lines: List[str] = []
lines: list[str] = []
if missing:
lines.append("Missing in meta.yaml run:")
for n in missing:
Expand All @@ -229,9 +228,7 @@ def main() -> int:
boto_deps = get_setup_extra_requires(setup_cfg_path, "boto")
# Make sure to update ci/anaconda/recipe/meta.yaml accordingly when there is dependency set update.
expected_deps = setup_deps + boto_deps
meta_deps = get_meta_run_requirements(
root / "ci" / "anaconda" / "recipe" / "meta.yaml"
)
meta_deps = get_meta_run_requirements(root / "ci" / "anaconda" / "recipe" / "meta.yaml")
diff = compare_deps(expected_deps, meta_deps)
if not diff:
return 0
Expand Down
6 changes: 2 additions & 4 deletions ci/change_snowflake_test_pwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@

import snowflake.connector

sys.path.append(
os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "test")
)

sys.path.append(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "test"))

CLIENT_KNOWN_SSM_FILE_PATH_DOCKER = "CLIENT_KNOWN_SSM_FILE_PATH_DOCKER"

Expand Down Expand Up @@ -46,7 +45,6 @@ def generate_known_ssm_file():

if __name__ == "__main__":
from jenkins_test_parameters import SNOWFLAKE_TEST_PASSWORD_NEW

from parameters import CONNECTION_PARAMETERS

change_password()
Expand Down
4 changes: 3 additions & 1 deletion ci/docker/connector_test_lambda/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import logging
import sys
import xml.etree.ElementTree as ET

from glob import glob
from pathlib import Path
from subprocess import PIPE, Popen


LOGGER = logging.getLogger(__name__)
REPO_PATH = "/home/user/snowflake-connector-python"
PY_SHORT_VER = f"{sys.version_info[0]}{sys.version_info[1]}" # 39, 310, 311, 312, 313
Expand All @@ -30,7 +32,7 @@ def run_tests():
for wheel in glob(f"{REPO_PATH}/dist/*.whl"):
args.extend(["--installpkg", wheel])

LOGGER.info(f"Popen args: {args}")
LOGGER.info("Popen args: %s", args)

test_log, err = Popen(
args,
Expand Down
Loading
Loading