Skip to content

Commit

Permalink
Merge branch 'main' into bump-mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
xrmx committed Mar 26, 2024
2 parents dd52013 + 29c293f commit 94b9b27
Show file tree
Hide file tree
Showing 23 changed files with 53 additions and 48 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#3778](https://github.com/open-telemetry/opentelemetry-python/pull/3778))
- Bump mypy to 1.9.0
([#3795](https://github.com/open-telemetry/opentelemetry-python/pull/3795))
- Fix license field in pyproject.toml files
([#3803](https://github.com/open-telemetry/opentelemetry-python/pull/3803))

## Version 1.23.0/0.44b0 (2024-02-23)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/error_handler/error_handler_0/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "error-handler-0"
dynamic = ["version"]
description = "This is just an error handler example package"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/error_handler/error_handler_1/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "error-handler-1"
dynamic = ["version"]
description = "This is just an error handler example package"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-opencensus/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-exporter-opencensus"
dynamic = ["version"]
description = "OpenCensus Exporter"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-exporter-otlp-proto-common"
dynamic = ["version"]
description = "OpenTelemetry Protobuf encoding"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-exporter-otlp-proto-grpc"
dynamic = ["version"]
description = "OpenTelemetry Collector Protobuf over gRPC Exporter"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-exporter-otlp-proto-http"
dynamic = ["version"]
description = "OpenTelemetry Collector Protobuf over HTTP Exporter"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-otlp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-exporter-otlp"
dynamic = ["version"]
description = "OpenTelemetry Collector Exporters"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-prometheus/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-exporter-prometheus"
dynamic = ["version"]
description = "Prometheus Metric Exporter for OpenTelemetry"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-zipkin-json/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-exporter-zipkin-json"
dynamic = ["version"]
description = "Zipkin Span JSON Exporter for OpenTelemetry"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-exporter-zipkin-proto-http"
dynamic = ["version"]
description = "Zipkin Span Protobuf Exporter for OpenTelemetry"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-zipkin/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-exporter-zipkin"
dynamic = ["version"]
description = "Zipkin Span Exporters for OpenTelemetry"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "hatchling.build"
name = "opentelemetry-api"
description = "OpenTelemetry Python API"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-proto/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-proto"
dynamic = ["version"]
description = "OpenTelemetry Python Proto"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-sdk"
dynamic = ["version"]
description = "OpenTelemetry Python SDK"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
27 changes: 14 additions & 13 deletions opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
Dict,
Iterator,
List,
MutableMapping,
Optional,
Sequence,
Tuple,
Expand Down Expand Up @@ -745,17 +746,17 @@ def __init__(
parent: Optional[trace_api.SpanContext] = None,
sampler: Optional[sampling.Sampler] = None,
trace_config: None = None, # TODO
resource: Resource = None,
resource: Optional[Resource] = None,
attributes: types.Attributes = None,
events: Sequence[Event] = None,
events: Optional[Sequence[Event]] = None,
links: Sequence[trace_api.Link] = (),
kind: trace_api.SpanKind = trace_api.SpanKind.INTERNAL,
span_processor: SpanProcessor = SpanProcessor(),
instrumentation_info: InstrumentationInfo = None,
instrumentation_info: Optional[InstrumentationInfo] = None,
record_exception: bool = True,
set_status_on_exception: bool = True,
limits=_UnsetLimits,
instrumentation_scope: InstrumentationScope = None,
instrumentation_scope: Optional[InstrumentationScope] = None,
) -> None:
if resource is None:
resource = Resource.create({})
Expand Down Expand Up @@ -994,7 +995,7 @@ def record_exception(
type(exception), value=exception, tb=exception.__traceback__
)
)
_attributes = {
_attributes: MutableMapping[str, types.AttributeValue] = {
"exception.type": exception.__class__.__name__,
"exception.message": str(exception),
"exception.stacktrace": stacktrace,
Expand Down Expand Up @@ -1045,7 +1046,7 @@ def start_as_current_span(
context: Optional[context_api.Context] = None,
kind: trace_api.SpanKind = trace_api.SpanKind.INTERNAL,
attributes: types.Attributes = None,
links: Sequence[trace_api.Link] = (),
links: Optional[Sequence[trace_api.Link]] = (),
start_time: Optional[int] = None,
record_exception: bool = True,
set_status_on_exception: bool = True,
Expand Down Expand Up @@ -1075,7 +1076,7 @@ def start_span( # pylint: disable=too-many-locals
context: Optional[context_api.Context] = None,
kind: trace_api.SpanKind = trace_api.SpanKind.INTERNAL,
attributes: types.Attributes = None,
links: Sequence[trace_api.Link] = (),
links: Optional[Sequence[trace_api.Link]] = (),
start_time: Optional[int] = None,
record_exception: bool = True,
set_status_on_exception: bool = True,
Expand Down Expand Up @@ -1152,15 +1153,15 @@ class TracerProvider(trace_api.TracerProvider):

def __init__(
self,
sampler: sampling.Sampler = None,
resource: Resource = None,
sampler: Optional[sampling.Sampler] = None,
resource: Optional[Resource] = None,
shutdown_on_exit: bool = True,
active_span_processor: Union[
SynchronousMultiSpanProcessor, ConcurrentMultiSpanProcessor
SynchronousMultiSpanProcessor, ConcurrentMultiSpanProcessor, None
] = None,
id_generator: IdGenerator = None,
span_limits: SpanLimits = None,
):
id_generator: Optional[IdGenerator] = None,
span_limits: Optional[SpanLimits] = None,
) -> None:
self._active_span_processor = (
active_span_processor or SynchronousMultiSpanProcessor()
)
Expand Down
32 changes: 17 additions & 15 deletions opentelemetry-sdk/src/opentelemetry/sdk/trace/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def __init__(
self,
decision: Decision,
attributes: "Attributes" = None,
trace_state: "TraceState" = None,
trace_state: Optional["TraceState"] = None,
) -> None:
self.decision = decision
if attributes is None:
Expand All @@ -201,10 +201,10 @@ def should_sample(
parent_context: Optional["Context"],
trace_id: int,
name: str,
kind: SpanKind = None,
kind: Optional[SpanKind] = None,
attributes: Attributes = None,
links: Sequence["Link"] = None,
trace_state: "TraceState" = None,
links: Optional[Sequence["Link"]] = None,
trace_state: Optional["TraceState"] = None,
) -> "SamplingResult":
pass

Expand All @@ -216,18 +216,18 @@ def get_description(self) -> str:
class StaticSampler(Sampler):
"""Sampler that always returns the same decision."""

def __init__(self, decision: "Decision"):
def __init__(self, decision: "Decision") -> None:
self._decision = decision

def should_sample(
self,
parent_context: Optional["Context"],
trace_id: int,
name: str,
kind: SpanKind = None,
kind: Optional[SpanKind] = None,
attributes: Attributes = None,
links: Sequence["Link"] = None,
trace_state: "TraceState" = None,
links: Optional[Sequence["Link"]] = None,
trace_state: Optional["TraceState"] = None,
) -> "SamplingResult":
if self._decision is Decision.DROP:
attributes = None
Expand Down Expand Up @@ -285,10 +285,10 @@ def should_sample(
parent_context: Optional["Context"],
trace_id: int,
name: str,
kind: SpanKind = None,
kind: Optional[SpanKind] = None,
attributes: Attributes = None,
links: Sequence["Link"] = None,
trace_state: "TraceState" = None,
links: Optional[Sequence["Link"]] = None,
trace_state: Optional["TraceState"] = None,
) -> "SamplingResult":
decision = Decision.DROP
if trace_id & self.TRACE_ID_LIMIT < self.bound:
Expand Down Expand Up @@ -340,10 +340,10 @@ def should_sample(
parent_context: Optional["Context"],
trace_id: int,
name: str,
kind: SpanKind = None,
kind: Optional[SpanKind] = None,
attributes: Attributes = None,
links: Sequence["Link"] = None,
trace_state: "TraceState" = None,
links: Optional[Sequence["Link"]] = None,
trace_state: Optional["TraceState"] = None,
) -> "SamplingResult":
parent_span_context = get_current_span(
parent_context
Expand Down Expand Up @@ -443,7 +443,9 @@ def _get_from_env_or_default() -> Sampler:
return _KNOWN_SAMPLERS[trace_sampler]


def _get_parent_trace_state(parent_context) -> Optional["TraceState"]:
def _get_parent_trace_state(
parent_context: Optional[Context],
) -> Optional["TraceState"]:
parent_span_context = get_current_span(parent_context).get_span_context()
if parent_span_context is None or not parent_span_context.is_valid:
return None
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-semantic-conventions/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-semantic-conventions"
dynamic = ["version"]
description = "OpenTelemetry Semantic Conventions"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion propagator/opentelemetry-propagator-b3/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-propagator-b3"
dynamic = ["version"]
description = "OpenTelemetry B3 Propagator"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion propagator/opentelemetry-propagator-jaeger/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-propagator-jaeger"
dynamic = ["version"]
description = "OpenTelemetry Jaeger Propagator"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion shim/opentelemetry-opencensus-shim/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-opencensus-shim"
dynamic = ["version"]
description = "OpenCensus Shim for OpenTelemetry"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion shim/opentelemetry-opentracing-shim/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-opentracing-shim"
dynamic = ["version"]
description = "OpenTracing Shim for OpenTelemetry"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down
2 changes: 1 addition & 1 deletion tests/opentelemetry-test-utils/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "opentelemetry-test-utils"
dynamic = ["version"]
description = "Test utilities for OpenTelemetry unit tests"
readme = "README.rst"
license = "Apache-2.0"
license = {text = "Apache-2.0"}
requires-python = ">=3.8"
authors = [
{ name = "OpenTelemetry Authors", email = "cncf-opentelemetry-contributors@lists.cncf.io" },
Expand Down

0 comments on commit 94b9b27

Please sign in to comment.