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

Fix type hint on prefix argument to AgentCheck.normalize() #6008

Merged

Conversation

florimondmanca
Copy link
Contributor

@florimondmanca florimondmanca commented Mar 10, 2020

What does this PR do?

Fix type hint on the prefix argument to AgentCheck.normalize(), as it actually handles both text and binary.

Also adds type annotations to ensure_bytes() and ensure_unicode() to fully type the .normalize() implementation.

Cleanup for #5965

Motivation

Mypy was improperly flagging errors in the SNMP check:

metric_name = self.normalize(name, prefix='snmp')

error: Argument "prefix" to "normalize" of "AgentCheck" has incompatible type "str"; expected "Optional[bytes]

Additional Notes

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have changelog/ and integration/ labels attached

@codecov
Copy link

codecov bot commented Mar 10, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@4d1dbc1). Click here to learn what that means.
The diff coverage is 100%.

Impacted Files Coverage Δ
...dog_checks_base/datadog_checks/base/checks/base.py 84.57% <100%> (ø)
...og_checks_base/datadog_checks/base/utils/common.py 90.38% <100%> (ø)

@florimondmanca florimondmanca merged commit 6b643db into master Mar 10, 2020
@florimondmanca florimondmanca deleted the florimondmanca/fix-normalize-prefix-type-hint branch March 10, 2020 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants