Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use importlib.metadata.version() to remove implicit dependency on setuptools #399

Merged
merged 2 commits into from
Sep 7, 2023
Merged
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
6 changes: 2 additions & 4 deletions dbt/adapters/athena/config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import importlib.metadata
from functools import lru_cache

import pkg_resources
from botocore import config


@lru_cache()
def get_boto3_config() -> config.Config:
return config.Config(
user_agent_extra="dbt-athena-community/" + pkg_resources.get_distribution("dbt-athena-community").version
)
return config.Config(user_agent_extra="dbt-athena-community/" + importlib.metadata.version("dbt-athena-community"))
5 changes: 2 additions & 3 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import importlib.metadata
from unittest.mock import Mock

import pkg_resources

from dbt.adapters.athena.config import get_boto3_config


class TestConfig:
def test_get_boto3_config(self):
pkg_resources.get_distribution = Mock(return_value=pkg_resources.Distribution(version="2.4.6"))
importlib.metadata.version = Mock(return_value="2.4.6")
get_boto3_config.cache_clear()
config = get_boto3_config()
assert config._user_provided_options["user_agent_extra"] == "dbt-athena-community/2.4.6"