diff --git a/pyproject.toml b/pyproject.toml index 4e3fc109e4..bf617604d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -365,7 +365,9 @@ ignore = [ python_version = "3.12" ignore_missing_imports = true namespace_packages = false - +pretty = true +show_error_code_links = true +show_error_context = true strict = true warn_unreachable = true enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] @@ -378,7 +380,6 @@ module = [ "tests.test_config", "tests.test_store.test_zip", "tests.test_store.test_local", - "tests.test_store.test_fsspec", "tests.test_store.test_memory", "tests.test_codecs.test_codecs", "tests.test_metadata.*", @@ -394,6 +395,7 @@ strict = false # and fix the errors [[tool.mypy.overrides]] module = [ + "tests.test_store.test_fsspec", "tests.test_group", "tests.test_indexing", "tests.test_properties", diff --git a/tests/test_store/test_fsspec.py b/tests/test_store/test_fsspec.py index 6e3dc192b8..142cb3b00d 100644 --- a/tests/test_store/test_fsspec.py +++ b/tests/test_store/test_fsspec.py @@ -80,7 +80,13 @@ def s3_base() -> Generator[None, None, None]: def get_boto3_client() -> botocore.client.BaseClient: # NB: we use the sync botocore client for setup session = botocore.session.Session() - return session.create_client("s3", endpoint_url=endpoint_url) + + # Prevent IllegalLocationConstraintException by explicitly setting region to + # "us-east-1", which does not require configuring LocationConstraint during + # bucket creation. (It is, in fact, forbidden for that region.) Necessary + # in the face of "ambient" AWS configuration in a development environment + # where the default region might be configured differently. + return session.create_client("s3", endpoint_url=endpoint_url, region_name="us-east-1") @pytest.fixture(autouse=True) @@ -100,7 +106,14 @@ def s3(s3_base: None) -> Generator[s3fs.S3FileSystem, None, None]: client = get_boto3_client() client.create_bucket(Bucket=test_bucket_name, ACL="public-read") s3fs.S3FileSystem.clear_instance_cache() - s3 = s3fs.S3FileSystem(anon=False, client_kwargs={"endpoint_url": endpoint_url}) + s3 = s3fs.S3FileSystem( + anon=False, + client_kwargs={"endpoint_url": endpoint_url}, + # Prevent "AssertionError: Session was never entered" from aiobotocore + # at end of test execution. Using clear_instance_cache is insufficient, + # although still necessary. + skip_instance_cache=True, + ) session = sync(s3.set_session()) s3.invalidate_cache() yield s3