Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[codespell]
# skipping auto generated folders
skip = ./.tox,./.mypy_cache,./docs/_build,./target,*/LICENSE,./venv,.git,./opentelemetry-semantic-conventions,*-requirements*.txt
skip = ./.tox,./docs/_build,./target,*/LICENSE,./venv,.git,./opentelemetry-semantic-conventions,*-requirements*.txt
ignore-words-list = ans,ue,ot,hist,ro
38 changes: 1 addition & 37 deletions .github/workflows/misc_0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,6 @@ jobs:
- name: Run tests
run: tox -e tracecontext

mypy:
name: mypy
runs-on: ubuntu-latest
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
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

pyright:
name: pyright
runs-on: ubuntu-latest
Expand All @@ -104,7 +68,7 @@ jobs:
run: pip install tox

- name: Run tests
run: tox -e pyright
run: tox -e typecheck

docs:
name: docs
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ htmlcov
# Sphinx
_build/

# mypy
.mypy_cache/
target

# Django example
Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ You can run `tox` with the following arguments:
- `tox -e lint-some-package` to run lint checks on `some-package`
- `tox -e generate-workflows` to run creation of new CI workflows if tox environments have been updated
- `tox -e ruff` to run ruff linter and formatter checks against the entire codebase
- `tox -e typecheck` to run pyright against entire code base.
- `tox -e public-symbols-check` to run public_symbols_checker.py.
- `tox -e docker-tests-{otlpexporter,opencensus}` to run tests in both or either one location.
- `tox -e tracecontext` to run integration tests for tracecontext.

`ruff check` and `ruff format` are executed when `tox -e ruff` is run. We strongly recommend you to configure [pre-commit](https://pre-commit.com/) locally to run `ruff` automatically before each commit by installing it as git hooks. You just need to [install pre-commit](https://pre-commit.com/#install) in your environment:

Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pylint==3.2.1
httpretty==1.1.4
mypy==1.9.0
pyright==1.1.394
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.

1 change: 0 additions & 1 deletion mypy-requirements.txt

This file was deleted.

22 changes: 0 additions & 22 deletions mypy.ini

This file was deleted.

2 changes: 1 addition & 1 deletion opentelemetry-sdk/tests/metrics/test_backward_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
and PeriodicExportingMetricReader concrete class. Those may freely be modified in a
backward-compatible way for *callers*.

Ideally, we could use mypy for this as well, but SDK is not type checked atm.
Ideally, we could use pyright for this as well, but SDK is not type checked atm.
"""

from typing import Iterable, Sequence
Expand Down
18 changes: 16 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,26 @@ addopts = "-rs -v"
log_cli = true

[tool.pyright]
typeCheckingMode = "off"
reportMissingTypeStubs = "error"
typeCheckingMode = "strict"
include = [
"opentelemetry-api/src",
"opentelemetry-sdk/src",
"opentelemetry-semantic-conventions/src",
"opentelemetry-proto/src",
"scripts"
]
ignore = [
"docs/**",
"exporter/**",
"propagator/**",
"shim/**",
]
reportUnnecessaryTypeIgnoreComment = true
pythonVersion = "3.9"
reportPrivateUsage = false # Ignore private attributes added by instrumentation packages.

exclude = [
"tests/**",
]

[tool.ruff]
Expand Down
2 changes: 1 addition & 1 deletion pyright-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pyright==1.1.381
pyright==1.1.394
18 changes: 2 additions & 16 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ envlist =

spellcheck
tracecontext
mypy,mypyinstalled
pyright
docs
docker-tests-{otlpexporter,opencensus}
Expand Down Expand Up @@ -144,7 +143,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 @@ -160,7 +158,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,
Expand Down Expand Up @@ -230,18 +227,7 @@ 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 Expand Up @@ -346,7 +332,7 @@ commands_pre =
commands =
sh -c "find {toxinidir} -name \*.sh | xargs shellcheck --severity=warning"

[testenv:pyright]
[testenv:typecheck]
basepython: python3
deps =
-r {toxinidir}/pyright-requirements.txt
Expand Down
Loading