Skip to content
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
38 changes: 0 additions & 38 deletions .github/workflows/misc_0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,44 +66,6 @@ jobs:
- name: Run tests
run: tox -e tracecontext

mypy:
name: mypy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e mypy

mypyinstalled:
name: mypyinstalled
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo @ SHA - ${{ github.sha }}
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e mypyinstalled

typecheck:
name: typecheck
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- typecheck: add sdk/resources and drop mypy
([#4578](https://github.com/open-telemetry/opentelemetry-python/pull/4578))
- Refactor `BatchLogRecordProcessor` to simplify code and make the control flow more
clear ([#4562](https://github.com/open-telemetry/opentelemetry-python/pull/4562/)
and [#4535](https://github.com/open-telemetry/opentelemetry-python/pull/4535)).


## Version 1.33.0/0.54b0 (2025-05-09)

- Fix intermittent `Connection aborted` error when using otlp/http exporters
Expand Down
1 change: 0 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pylint==3.3.4
httpretty==1.1.4
pyright==1.1.396
mypy==1.9.0
sphinx==7.1.2
sphinx-rtd-theme==2.0.0rc4
sphinx-autodoc-typehints==1.25.2
Expand Down
22 changes: 0 additions & 22 deletions mypy-relaxed.ini

This file was deleted.

22 changes: 0 additions & 22 deletions mypy.ini

This file was deleted.

28 changes: 14 additions & 14 deletions opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
from json import dumps
from os import environ
from types import ModuleType
from typing import List, MutableMapping, Optional, cast
from typing import List, Optional, cast
from urllib import parse

from opentelemetry.attributes import BoundedAttributes
Expand All @@ -77,7 +77,10 @@
OTEL_SERVICE_NAME,
)
from opentelemetry.semconv.resource import ResourceAttributes
from opentelemetry.util._importlib_metadata import entry_points, version
from opentelemetry.util._importlib_metadata import (
entry_points, # type: ignore[reportUnknownVariableType]
version,
)
from opentelemetry.util.types import AttributeValue

psutil: Optional[ModuleType] = None
Expand Down Expand Up @@ -210,7 +213,7 @@ def create(
entry_points(
group="opentelemetry_resource_detector",
name=resource_detector.strip(),
) # type: ignore
) # type: ignore[reportUnknownArgumentType]
)
).load()()
)
Expand Down Expand Up @@ -266,8 +269,8 @@ def merge(self, other: "Resource") -> "Resource":
Returns:
The newly-created Resource.
"""
merged_attributes = self.attributes.copy() # type: ignore
merged_attributes.update(other.attributes) # type: ignore
merged_attributes = dict(self.attributes).copy()
merged_attributes.update(other.attributes)

if self.schema_url == "":
schema_url = other.schema_url
Expand All @@ -282,7 +285,7 @@ def merge(self, other: "Resource") -> "Resource":
other.schema_url,
)
return self
return Resource(merged_attributes, schema_url) # type: ignore
return Resource(merged_attributes, schema_url)

def __eq__(self, other: object) -> bool:
if not isinstance(other, Resource):
Expand All @@ -294,16 +297,13 @@ def __eq__(self, other: object) -> bool:

def __hash__(self) -> int:
return hash(
f"{dumps(self._attributes.copy(), sort_keys=True)}|{self._schema_url}" # type: ignore
f"{dumps(self._attributes.copy(), sort_keys=True)}|{self._schema_url}"
)

def to_json(self, indent: Optional[int] = 4) -> str:
attributes: MutableMapping[str, AttributeValue] = dict(
self._attributes
)
return dumps(
{
"attributes": attributes, # type: ignore
"attributes": dict(self.attributes),
"schema_url": self._schema_url,
},
indent=indent,
Expand Down Expand Up @@ -334,7 +334,7 @@ class OTELResourceDetector(ResourceDetector):
# pylint: disable=no-self-use
def detect(self) -> "Resource":
env_resources_items = environ.get(OTEL_RESOURCE_ATTRIBUTES)
env_resource_map = {}
env_resource_map: dict[str, AttributeValue] = {}

if env_resources_items:
for item in env_resources_items.split(","):
Expand Down Expand Up @@ -392,7 +392,7 @@ def detect(self) -> "Resource":
resource_info[PROCESS_PARENT_PID] = os.getppid()

if psutil is not None:
process: psutil_module.Process = psutil.Process()
process = psutil.Process()
username = process.username()
resource_info[PROCESS_OWNER] = username

Expand Down Expand Up @@ -483,7 +483,7 @@ def detect(self) -> "Resource":
)


class _HostResourceDetector(ResourceDetector):
class _HostResourceDetector(ResourceDetector): # type: ignore[reportUnusedClass]
"""
The HostResourceDetector detects the hostname and architecture attributes.
"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ exclude = [
"opentelemetry-sdk/src/opentelemetry/sdk/_events",
"opentelemetry-sdk/src/opentelemetry/sdk/_logs",
"opentelemetry-sdk/src/opentelemetry/sdk/error_handler",
"opentelemetry-sdk/src/opentelemetry/sdk/resources",
"opentelemetry-sdk/src/opentelemetry/sdk/metrics",
"opentelemetry-sdk/src/opentelemetry/sdk/trace",
"opentelemetry-sdk/src/opentelemetry/sdk/util",
Expand All @@ -124,4 +123,5 @@ exclude = [
strict = [
"opentelemetry-semantic-conventions",
"opentelemetry-sdk/src/opentelemetry/sdk/environment_variables",
"opentelemetry-sdk/src/opentelemetry/sdk/resources",
]
18 changes: 0 additions & 18 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ envlist =

spellcheck
tracecontext
mypy,mypyinstalled
typecheck
docs
docker-tests-{otlpexporter,opencensus}
Expand All @@ -103,9 +102,6 @@ deps =
coverage: pytest
coverage: pytest-cov

mypy,mypyinstalled: -c {toxinidir}/dev-requirements.txt
mypy,mypyinstalled: mypy

api: -r {toxinidir}/opentelemetry-api/test-requirements.txt

sdk: -r {toxinidir}/opentelemetry-sdk/test-requirements.txt
Expand Down Expand Up @@ -145,7 +141,6 @@ deps =

propagator-jaeger: -r {toxinidir}/propagator/opentelemetry-propagator-jaeger/test-requirements.txt

mypyinstalled: -e {toxinidir}/opentelemetry-api

getting-started: -r {toxinidir}/docs/getting_started/tests/requirements.txt
getting-started: {env:CONTRIB_REPO}\#egg=opentelemetry-util-http&subdirectory=util/opentelemetry-util-http
Expand All @@ -161,7 +156,6 @@ setenv =
; i.e: CONTRIB_REPO_SHA=dde62cebffe519c35875af6d06fae053b3be65ec tox -e <env to test>
CONTRIB_REPO_SHA={env:CONTRIB_REPO_SHA:main}
CONTRIB_REPO=git+https://github.com/open-telemetry/opentelemetry-python-contrib.git@{env:CONTRIB_REPO_SHA}
mypy: MYPYPATH={toxinidir}/opentelemetry-api/src/:{toxinidir}/opentelemetry-semantic-conventions/src/:{toxinidir}/opentelemetry-sdk/src/:{toxinidir}/tests/opentelemetry-test-utils/src/
commands_pre =
; In order to get a healthy coverage report,
; we have to install packages in editable mode.
Expand Down Expand Up @@ -230,18 +224,6 @@ commands =

coverage: {toxinidir}/scripts/coverage.sh

mypy: mypy --version
mypy: mypy --install-types --non-interactive --namespace-packages --explicit-package-bases opentelemetry-api/src/opentelemetry/
mypy: mypy --install-types --non-interactive --namespace-packages --explicit-package-bases opentelemetry-sdk/src/opentelemetry/sdk/resources
mypy: mypy --install-types --non-interactive --namespace-packages --explicit-package-bases opentelemetry-semantic-conventions/src/opentelemetry/semconv/

; For test code, we don't want to enforce the full mypy strictness
mypy: mypy --install-types --non-interactive --namespace-packages --config-file=mypy-relaxed.ini opentelemetry-api/tests/

; Test that mypy can pick up typeinfo from an installed package (otherwise,
; implicit Any due to unfollowed import would result).
mypyinstalled: mypy --install-types --non-interactive --namespace-packages opentelemetry-api/tests/mypysmoke.py --strict

[testenv:spellcheck]
basepython: python3
recreate = True
Expand Down