From 18497879dca27a0543dd2327cdce01b3337d07bf Mon Sep 17 00:00:00 2001 From: laughingman7743 Date: Sun, 12 Jan 2025 15:17:03 +0900 Subject: [PATCH] Pin the version of uv and tox --- Makefile | 4 ++-- pyathena/connection.py | 6 +++--- pyathena/sqlalchemy/base.py | 3 +-- tests/__init__.py | 12 ++++++------ tests/pyathena/filesystem/test_s3.py | 20 +++++--------------- tests/pyathena/pandas/test_util.py | 3 +-- tests/pyathena/test_model.py | 2 +- 7 files changed, 19 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index cd13c145..7d02c757 100644 --- a/Makefile +++ b/Makefile @@ -28,5 +28,5 @@ docs: .PHONY: tool tool: - uv tool install ruff - uv tool install tox --with tox-uv --with tox-gh-actions + uv tool install ruff@0.9.1 + uv tool install tox@4.23.2 --with tox-uv --with tox-gh-actions diff --git a/pyathena/connection.py b/pyathena/connection.py index 5d4cd0d2..25595e21 100644 --- a/pyathena/connection.py +++ b/pyathena/connection.py @@ -175,9 +175,9 @@ def __init__( self.profile_name = profile_name self.config: Optional[Config] = config if config else Config() - assert ( - self.s3_staging_dir or self.work_group - ), "Required argument `s3_staging_dir` or `work_group` not found." + assert self.s3_staging_dir or self.work_group, ( + "Required argument `s3_staging_dir` or `work_group` not found." + ) if session: self._session = session diff --git a/pyathena/sqlalchemy/base.py b/pyathena/sqlalchemy/base.py index d594756f..5b5c295e 100644 --- a/pyathena/sqlalchemy/base.py +++ b/pyathena/sqlalchemy/base.py @@ -702,8 +702,7 @@ def _get_table_location_specification( else: if connect_opts: raise exc.CompileError( - "`location` or `s3_staging_dir` parameter is required " - "in the connection string" + "`location` or `s3_staging_dir` parameter is required in the connection string" ) raise exc.CompileError( "The location of the table should be specified " diff --git a/tests/__init__.py b/tests/__init__.py index 3dab34a4..d2a21f02 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -14,18 +14,18 @@ def __init__(self): self.region_name = os.getenv("AWS_DEFAULT_REGION") assert self.region_name, "Required environment variable `AWS_DEFAULT_REGION` not found." self.s3_staging_dir = os.getenv("AWS_ATHENA_S3_STAGING_DIR") - assert ( - self.s3_staging_dir - ), "Required environment variable `AWS_ATHENA_S3_STAGING_DIR` not found." + assert self.s3_staging_dir, ( + "Required environment variable `AWS_ATHENA_S3_STAGING_DIR` not found." + ) self.s3_staging_bucket, self.s3_staging_key = self.s3_staging_dir.replace( "s3://", "" ).split("/", 1) self.work_group = os.getenv("AWS_ATHENA_WORKGROUP") assert self.work_group, "Required environment variable `AWS_ATHENA_WORKGROUP` not found." self.spark_work_group = os.getenv("AWS_ATHENA_SPARK_WORKGROUP") - assert ( - self.spark_work_group - ), "Required environment variable `AWS_ATHENA_SPARK_WORKGROUP` not found." + assert self.spark_work_group, ( + "Required environment variable `AWS_ATHENA_SPARK_WORKGROUP` not found." + ) self.default_work_group = os.getenv("AWS_ATHENA_DEFAULT_WORKGROUP", "primary") self.schema = "pyathena_test_" + "".join( [random.choice(string.ascii_lowercase + string.digits) for _ in range(10)] diff --git a/tests/pyathena/filesystem/test_s3.py b/tests/pyathena/filesystem/test_s3.py index 5f9704b0..dd514aa7 100644 --- a/tests/pyathena/filesystem/test_s3.py +++ b/tests/pyathena/filesystem/test_s3.py @@ -253,8 +253,7 @@ def test_ls_buckets(self, fs): def test_ls_dirs(self, fs): dir_ = ( - f"s3://{ENV.s3_staging_bucket}/{ENV.s3_staging_key}{ENV.schema}/" - f"filesystem/test_ls_dirs" + f"s3://{ENV.s3_staging_bucket}/{ENV.s3_staging_key}{ENV.schema}/filesystem/test_ls_dirs" ) for i in range(5): fs.pipe(f"{dir_}/prefix/test_{i}", bytes(i)) @@ -362,10 +361,7 @@ def test_info_file(self, fs): def test_find(self, fs): # TODO maxdepsth and withdirs options - dir_ = ( - f"s3://{ENV.s3_staging_bucket}/{ENV.s3_staging_key}{ENV.schema}/" - f"filesystem/test_find" - ) + dir_ = f"s3://{ENV.s3_staging_bucket}/{ENV.s3_staging_key}{ENV.schema}/filesystem/test_find" for i in range(5): fs.pipe(f"{dir_}/prefix/test_{i}", bytes(i)) fs.touch(f"{dir_}/prefix2") @@ -393,10 +389,7 @@ def test_du(self): pass def test_glob(self, fs): - dir_ = ( - f"s3://{ENV.s3_staging_bucket}/{ENV.s3_staging_key}{ENV.schema}/" - f"filesystem/test_glob" - ) + dir_ = f"s3://{ENV.s3_staging_bucket}/{ENV.s3_staging_key}{ENV.schema}/filesystem/test_glob" path = f"{dir_}/nested/test_{uuid.uuid4()}" fs.touch(path) @@ -433,8 +426,7 @@ def test_exists_object(self, fs): def test_rm_file(self, fs): dir_ = ( - f"s3://{ENV.s3_staging_bucket}/{ENV.s3_staging_key}{ENV.schema}/" - f"filesystem/test_rm_rile" + f"s3://{ENV.s3_staging_bucket}/{ENV.s3_staging_key}{ENV.schema}/filesystem/test_rm_rile" ) file = f"{dir_}/{uuid.uuid4()}" fs.touch(file) @@ -444,9 +436,7 @@ def test_rm_file(self, fs): assert not fs.exists(dir_) def test_rm(self, fs): - dir_ = ( - f"s3://{ENV.s3_staging_bucket}/{ENV.s3_staging_key}{ENV.schema}/" f"filesystem/test_rm" - ) + dir_ = f"s3://{ENV.s3_staging_bucket}/{ENV.s3_staging_key}{ENV.schema}/filesystem/test_rm" file = f"{dir_}/{uuid.uuid4()}" fs.touch(file) fs.rm(file) diff --git a/tests/pyathena/pandas/test_util.py b/tests/pyathena/pandas/test_util.py index c71b4c84..1bf18990 100644 --- a/tests/pyathena/pandas/test_util.py +++ b/tests/pyathena/pandas/test_util.py @@ -573,6 +573,5 @@ def test_to_sql_invalid_args(cursor): partitions=["partition_key"], ) assert str(exc_info.value) == ( - "Partition key: `partition_key` contains None values, " - "no data will be written to the table." + "Partition key: `partition_key` contains None values, no data will be written to the table." ) diff --git a/tests/pyathena/test_model.py b/tests/pyathena/test_model.py index e6a20559..a1c73188 100644 --- a/tests/pyathena/test_model.py +++ b/tests/pyathena/test_model.py @@ -235,7 +235,7 @@ def _create_table_metadata_parameters_parquet(self): "parquet.compress": "SNAPPY", "serde.param.serialization.format": "1", "serde.serialization.lib": ( - "org.apache.hadoop.hive.ql.io.parquet.serde." "ParquetHiveSerDe" + "org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe" ), "transient_lastDdlTime": "1234567890", }