diff --git a/.github/workflows/build-package.yml b/.github/workflows/build-package.yml new file mode 100644 index 0000000..a7b0b94 --- /dev/null +++ b/.github/workflows/build-package.yml @@ -0,0 +1,33 @@ +name: Build distribution 📦 + +on: + workflow_call: + workflow_dispatch: + pull_request: + +jobs: + build-package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install hatch + run: | + pip install hatch --user + + - name: Run tests + run: | + python3 -m hatch run test + + - name: Run linting + run: | + python3 -m hatch run lint:all + + - name: Build a wheel and a source tarball + run: | + python3 -m hatch build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bb71f5f..9c5cff6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,41 +4,23 @@ on: jobs: build-package: - name: Build distribution 📦 - runs-on: ubuntu-latest + uses: ./.github/workflows/build-package.yml + check-tag: + runs-on: ubuntu-latest steps: - id: check_ref run: echo "::set-output name=match::$(echo '${{ github.ref }}' | grep -Pq '^refs/tags/v\d+\.\d+\.\d+$' && echo true || echo false)" shell: bash - - name: Check if tag is valid if: steps.check_ref.outputs.match != 'true' run: exit 1 + upload-artifact: + needs: build-package + runs-on: ubuntu-latest + steps: - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - - name: Install hatch - run: | - pip install hatch --user - - - name: Run tests - run: | - python3 -m hatch run test - - - name: Run linting - run: | - python3 -m hatch run lint:all - - - name: Build a wheel and a source tarball - run: | - python3 -m hatch build - - name: Store the distribution packages uses: actions/upload-artifact@v4 with: diff --git a/dynatrace_extension/sdk/communication.py b/dynatrace_extension/sdk/communication.py index 7a89fce..28607bb 100644 --- a/dynatrace_extension/sdk/communication.py +++ b/dynatrace_extension/sdk/communication.py @@ -343,7 +343,7 @@ def get_extension_config(self) -> str: def get_feature_sets(self) -> dict[str, list[str]]: # This is only called from dt-sdk run, where PyYaml is installed because of dt-cli # Do NOT move this to the top of the file - import yaml # type: ignore + import yaml # noqa: PLC0415 # Grab the feature sets from the extension.yaml file extension_yaml = yaml.safe_load(self.extension_config) diff --git a/dynatrace_extension/sdk/extension.py b/dynatrace_extension/sdk/extension.py index 50eac83..36fbe86 100644 --- a/dynatrace_extension/sdk/extension.py +++ b/dynatrace_extension/sdk/extension.py @@ -184,7 +184,7 @@ class Extension: def __new__(cls, *args, **kwargs): # noqa: ARG004 if Extension._instance is None: - Extension._instance = super(__class__, cls).__new__(cls) + Extension._instance = super().__new__(cls) return Extension._instance def __init__(self, name: str = "") -> None: @@ -683,7 +683,7 @@ def report_dt_event_dict(self, event: dict): msg = f"Event type must be a DtEventType enum value, got: {value}" raise ValueError(msg) if key == "properties": - for prop_key, prop_val in event[key].items(): + for prop_key, prop_val in value.items(): if not isinstance(prop_key, str) or not isinstance(prop_val, str): msg = f'invalid "properties" member: {prop_key}: {prop_val}, required: "str": str' raise ValueError(msg) diff --git a/dynatrace_extension/sdk/status.py b/dynatrace_extension/sdk/status.py index f00fa92..21c02d9 100644 --- a/dynatrace_extension/sdk/status.py +++ b/dynatrace_extension/sdk/status.py @@ -114,6 +114,9 @@ def __repr__(self): def __eq__(self, other): return isinstance(other, EndpointStatus) and self.__dict__ == other.__dict__ + def __hash__(self): + return hash(tuple(sorted(self.__dict__.items()))) + class EndpointStatuses: def __init__(self, total_endpoints_number=None) -> None: