DataDog / dd-trace-py

Datadog Python APM Client
https://ddtrace.readthedocs.io/
Other
546 stars 411 forks source link

Typing issue with set_http_meta #7978

Closed shughes-uk closed 9 months ago

shughes-uk commented 9 months ago

Summary of problem

set_http_meta seems to be typed too strictly to accept anything in existing contributed code.

_JSONType | Unknown is incompatible with the IntegrationConfig type

For example the falcon integration.

https://github.com/DataDog/dd-trace-py/blob/4577f757cc8ab750d1fdbfae1fb767dcbacf6f22/ddtrace/contrib/falcon/middleware.py#L49C1-L51C10

pyright/pylance will error here with

Argument of type "_JSONType | Unknown" cannot be assigned to parameter "integration_config" of type "IntegrationConfig" in function "set_http_meta"
  Type "_JSONType | Unknown" cannot be assigned to type "IntegrationConfig"
    "float" is incompatible with "IntegrationConfig"

Which version of dd-trace-py are you using?

2.4.0

Which version of pip are you using?

23.3

How can we reproduce your problem?

VSCode + pylance / npx pyright / grab pyright from pypi and run it

emmettbutler commented 9 months ago

Thanks for the report, @shughes-uk. I've opened https://github.com/DataDog/dd-trace-py/pull/8013 that I think fixes the issue.