-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add mypy typing to datadog_checks_base for db utils #7867
Conversation
Style is failing. You can fix it with |
""" | ||
Given an already obfuscated & normalized SQL query, generate its 64-bit hex signature. | ||
""" | ||
if not normalized_query: | ||
return None | ||
# Note: please be cautious when changing this function as some features rely on this | ||
# hash matching the APM resource hash generated on our backend. | ||
return format(mmh3.hash64(normalized_query, signed=False)[0], 'x') | ||
return format(mmh3.hash64(normalized_query, signed=False)[0], str('x')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
str('x')
This looks weird, what is the motivation for this syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I'm using from __future__ import unicode_literals
, the 'x' is a unicode string (py2) being passed to format, which only accepts ascii str
as an argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay! So just to be sure, this is unrelated to typing, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, no it is due to typing. The error is from mypy, but does not produce a code execption in py2.
datadog_checks_base/datadog_checks/base/utils/db/statement_metrics.py
Outdated
Show resolved
Hide resolved
e1d23fc
to
44b281a
Compare
2096184
to
ed858ac
Compare
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Note that this will not be automatically closed, but the notification will remind us to investigate why there's been inactivity. |
Typo Add db files to mypy Fix imports Fix typing errors Typing fixes
ed858ac
to
559dbe7
Compare
What does this PR do?
As a follow-up to #7837, add the mypy typing to the added functions.
Motivation
This was requested as part of the PR, but I decided to make it a fast follow-on to reduce risk.
Additional Notes
Review checklist (to be filled by reviewers)
changelog/
andintegration/
labels attached