Skip to content

Commit

Permalink
Merge branch 'main' into protobuf5
Browse files Browse the repository at this point in the history
  • Loading branch information
emdneto authored Oct 2, 2024
2 parents 3e428f7 + 01a670e commit ba9314e
Show file tree
Hide file tree
Showing 41 changed files with 74 additions and 8 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/misc_0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@ jobs:
- name: Run tests
run: tox -e mypyinstalled

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

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

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e pyright

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

## Unreleased

- Removed superfluous py.typed markers and added them where they were missing
([#4172](https://github.com/open-telemetry/opentelemetry-python/pull/4172))
- Include metric info in encoding exceptions
([#4154](https://github.com/open-telemetry/opentelemetry-python/pull/4154))
- sdk: Add support for log formatting
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pylint==3.0.2
pylint==3.2.1
flake8==6.1.0
isort==5.12.0
black==24.3.0
Expand Down
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ def collect(self) -> Iterable[PrometheusMetric]:
)

if metric_family_id_metric_family:
for metric_family in metric_family_id_metric_family.values():
yield metric_family
yield from metric_family_id_metric_family.values()

# pylint: disable=too-many-locals,too-many-branches
def _translate_to_prometheus(
Expand Down
Empty file.
Empty file.
Empty file.
Empty file removed opentelemetry-api/py.typed
Empty file.
14 changes: 14 additions & 0 deletions opentelemetry-api/src/opentelemetry/util/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@

from typing import Mapping, Optional, Sequence, Tuple, Union

# This is the implementation of the "Any" type as specified by the specifications of OpenTelemetry data model for logs.
# For more details, refer to the OTel specification:
# https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#type-any
AnyValue = Union[
str,
bool,
int,
float,
bytes,
Sequence["AnyValue"],
Mapping[str, "AnyValue"],
None,
]

AttributeValue = Union[
str,
bool,
Expand Down
Empty file removed opentelemetry-proto/py.typed
Empty file.
Empty file removed opentelemetry-sdk/py.typed
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
get_current_span,
)
from opentelemetry.trace.span import TraceFlags
from opentelemetry.util.types import Attributes
from opentelemetry.util.types import AnyValue, Attributes

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -179,7 +179,7 @@ def __init__(
trace_flags: Optional[TraceFlags] = None,
severity_text: Optional[str] = None,
severity_number: Optional[SeverityNumber] = None,
body: Optional[Any] = None,
body: Optional[AnyValue] = None,
resource: Optional[Resource] = None,
attributes: Optional[Attributes] = None,
limits: Optional[LogLimits] = _UnsetLogLimits,
Expand Down
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def collect(self) -> Optional[MetricsData]:
metrics.append(
Metric(
# pylint: disable=protected-access
# pylint: disable=possibly-used-before-assignment
name=view_instrument_match._name,
description=view_instrument_match._description,
unit=view_instrument_match._instrument.unit,
Expand Down
Empty file.
Empty file.
Empty file.
7 changes: 5 additions & 2 deletions opentelemetry-sdk/src/opentelemetry/sdk/util/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def get_dict_as_key(
labels: Mapping[str, AttributeValue]
) -> AttributesAsKey: ...

# pylint: disable=no-self-use
class BoundedList(Sequence[_T]):
"""An append only list with a fixed max size.
Expand All @@ -51,7 +52,9 @@ class BoundedList(Sequence[_T]):
def append(self, item: _T): ...
def extend(self, seq: Sequence[_T]): ...
@classmethod
def from_seq(cls, maxlen: int, seq: Iterable[_T]) -> BoundedList[_T]: ...
def from_seq(
cls, maxlen: int, seq: Iterable[_T]
) -> BoundedList[_T]: ... # pylint: disable=undefined-variable

class BoundedDict(MutableMapping[_KT, _VT]):
"""An ordered dict with a fixed max capacity.
Expand All @@ -70,4 +73,4 @@ class BoundedDict(MutableMapping[_KT, _VT]):
@classmethod
def from_map(
cls, maxlen: int, mapping: Mapping[_KT, _VT]
) -> BoundedDict[_KT, _VT]: ...
) -> BoundedDict[_KT, _VT]: ... # pylint: disable=undefined-variable
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,9 @@ def test_exponent_index_min(self):

self.assertEqual(
exponent_mapping.map_to_index(
nextafter(MIN_NORMAL_VALUE, inf)
nextafter( # pylint: disable=possibly-used-before-assignment
MIN_NORMAL_VALUE, inf
)
),
MIN_NORMAL_EXPONENT >> -scale,
)
1 change: 1 addition & 0 deletions opentelemetry-sdk/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from opentelemetry.sdk.util import BoundedList


# pylint: disable=unsubscriptable-object
class TestBoundedList(unittest.TestCase):
base = [52, 36, 53, 29, 54, 99, 56, 48, 22, 35, 21, 65, 10, 95, 42, 60]

Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ exclude = '''
[tool.pytest.ini_options]
addopts = "-rs -v"
log_cli = true

[tool.pyright]
typeCheckingMode = "off"
reportMissingTypeStubs = "error"
include = [
"opentelemetry-api/src",
"opentelemetry-sdk/src",
"opentelemetry-semantic-conventions/src",
]
1 change: 1 addition & 0 deletions pyright-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyright==1.1.381
16 changes: 16 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ envlist =
spellcheck
tracecontext
mypy,mypyinstalled
pyright
docs
docker-tests-proto
public-symbols-check
Expand Down Expand Up @@ -434,3 +435,18 @@ commands_pre =

commands =
sh -c "find {toxinidir} -name \*.sh | xargs shellcheck --severity=warning"

[testenv:pyright]
basepython: python3

allowlist_externals = pyright

commands_pre =
pip install -r {toxinidir}/pyright-requirements.txt \
-e {toxinidir}/opentelemetry-api \
-e {toxinidir}/opentelemetry-semantic-conventions \
-e {toxinidir}/opentelemetry-sdk

commands =
pyright --version
pyright

0 comments on commit ba9314e

Please sign in to comment.