Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tox doesn't run mypy on the sdk code #773

Open
aabmass opened this issue Jun 3, 2020 · 6 comments · May be fixed by #3809
Open

Tox doesn't run mypy on the sdk code #773

aabmass opened this issue Jun 3, 2020 · 6 comments · May be fixed by #3809

Comments

@aabmass
Copy link
Member

aabmass commented Jun 3, 2020

Currently, tox.ini only has mypy running on the api, so the sdk is not covered in CI:

mypy: mypy --namespace-packages opentelemetry-api/src/opentelemetry/
; For test code, we don't want to enforce the full mypy strictness
mypy: mypy --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 --namespace-packages opentelemetry-api/tests/mypysmoke.py --strict

See the commands in an example run:

$ tox -e mypy
mypy installed: mypy==0.770,mypy-extensions==0.4.3,typed-ast==1.4.1,typing-extensions==3.7.4.2
mypy run-test-pre: PYTHONHASHSEED='1981813759'
mypy run-test: commands[0] | mypy --namespace-packages opentelemetry-api/src/opentelemetry/
Success: no issues found in 21 source files
mypy run-test: commands[1] | mypy --namespace-packages --config-file=mypy-relaxed.ini opentelemetry-api/tests/
Success: no issues found in 20 source files
__________________________________________________________________ summary ___________________________________________________________________
  mypy: commands succeeded
  congratulations :)
@github-actions
Copy link

github-actions bot commented Apr 9, 2021

This issue was marked stale due to lack of activity. It will be closed in 30 days.

@flyinprogrammer
Copy link

it'd be nice if we upgraded mypy to > 0.930 so that it can install typed_ast > 1.5.0 - so that this project can work natively on M1. As it stands now it fails to run because typed_ast@1.4.3 doesn't compile on M1.

@codeboten
Copy link
Contributor

it'd be nice if we upgraded mypy to > 0.930 so that it can install typed_ast > 1.5.0 - so that this project can work natively on M1. As it stands now it fails to run because typed_ast@1.4.3 doesn't compile on M1.

Thanks for the suggestion @flyinprogrammer, I've created a separate issue to track that, would you be interested in submitting a PR for it?

@flyinprogrammer
Copy link

i want to be the hero you're looking for, i think it's gonna take me a minute though 🥲

@rajat315315
Copy link
Contributor

rajat315315 commented Jul 19, 2023

Does it run now? As it seems, we have upgraded version of mypy to >0.930
Can we close this?

@ocelotl
Copy link
Contributor

ocelotl commented Aug 7, 2023

We would need first to run mypy on the SDK files too:

diff --git a/tox.ini b/tox.ini
index ce3733729..1b712b030 100644
--- a/tox.ini
+++ b/tox.ini
@@ -96,7 +96,7 @@ 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}/tests/opentelemetry-test-utils/src/
+  mypy: MYPYPATH={toxinidir}/opentelemetry-api/src/:{toxinidir}/opentelemetry-sdk/src/:{toxinidir}/tests/opentelemetry-test-utils/src/
 
 changedir =
   api: opentelemetry-api/tests
@@ -195,7 +195,7 @@ commands =
   opentelemetry: pytest {posargs}
   coverage: {toxinidir}/scripts/coverage.sh
 
-  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-api/src/opentelemetry/ opentelemetry-sdk/src/opentelemetry/sdk/
 
 ; 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/

I tried running tox -e mypy with these changes and noticed many failures.

@aabmass aabmass linked a pull request Mar 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants