newrelic / newrelic-python-agent

New Relic Python Agent
https://docs.newrelic.com/docs/agents/python-agent
Apache License 2.0
176 stars 99 forks source link

Public interface should allow type checking #1179

Closed sh-at-cs closed 2 months ago

sh-at-cs commented 2 months ago

Is your feature request related to a problem? Please describe.

As far as I'm aware, the New Relic Python package (I hope this is the right repository?) doesn't currently have any type hints and naturally also no py.typed marker. As a consequence, when users try to typecheck code which imports it using static type checkers like Mypy or Pyright, they get errors like (this is for Mypy, it'll look similar for other checkers):

error: Skipping analyzing "newrelic.agent": module is installed, but missing library stubs or py.typed marker  [import-untyped]

Feature Description

It would be great if there were type hints (either inline or as separate stub files) for the parts of the New Relic Python package that constitute its public interface, so that users can typecheck the parts of their code that call New Relic explicitly.

Describe Alternatives

Users can currently work around the type checking errors themselves by adding # type: ignore comments for the imports, but that is not ideal, as static type checking is really useful and standard for modern Python.

Additional context

Being able to type check calls into New Relic is especially important when breaking API changes are introduced - without types, there is no way to notice these unless your tests happen to catch them (which is not a given, considering instrumentation like New Relic's is not usually enabled for tests, let alone tested explicitly).

Priority

Really Want (IMHO)

workato-integration[bot] commented 2 months ago

https://new-relic.atlassian.net/browse/NR-292031

lrafeei commented 2 months ago

Hello--As of now, we cannot add this functionality since we still support Python 2.7 (which we will be dropping support for in the near future). I will close this ticket for now and re-open it to add it as a feature request once we officially drop 2.7 support.

sh-at-cs commented 2 months ago

If you ship the types as stub files, it won't affect Python 2.7 users whatsoever.

lrafeei commented 2 months ago

Reopening this feature request

workato-integration[bot] commented 2 months ago

Work has been completed on this issue.

workato-integration[bot] commented 2 months ago

Work has been completed on this issue.