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

Properly create list of known options when detecting typos #11482

Merged
merged 4 commits into from
Feb 11, 2022

Conversation

sarah-witt
Copy link
Contributor

@sarah-witt sarah-witt commented Feb 9, 2022

What does this PR do?

Properly create list of known options when validating typos
Fixes: #11211

Motivation

Redis tests were failing with:

tests/test_slowlog.py:56: in test_custom_slowlog
    dd_run_check(redis_check)
../datadog_checks_dev/datadog_checks/dev/plugin/pytest.py:219: in run_check
    raise Exception('\n'.join(exc_lines))
E   Exception: 
E   Traceback (most recent call last):
E     File "/home/vsts/work/1/s/datadog_checks_base/datadog_checks/base/checks/base.py", line 1041, in run
E       initialization()
E     File "/home/vsts/work/1/s/datadog_checks_base/datadog_checks/base/utils/tracing.py", line 77, in wrapper
E       return f(self, *args, **kwargs)
E     File "/home/vsts/work/1/s/datadog_checks_base/datadog_checks/base/checks/base.py", line 455, in load_configuration_models
E       self.log_typos_in_options(intg_instance_config, instance_config, 'instances')
E     File "/home/vsts/work/1/s/datadog_checks_base/datadog_checks/base/utils/tracing.py", line 77, in wrapper
E       return f(self, *args, **kwargs)
E     File "/home/vsts/work/1/s/datadog_checks_base/datadog_checks/base/checks/base.py", line 414, in log_typos_in_options
E       known_options = dict(models_config).keys()
E   TypeError: attribute of type 'tuple' is not callable

This was happening because redis had a config option named keys

Additional Notes

Also updated the tests to input classes instead of dictionaries to mirror the actual input better, as well as added more type hints in the function.

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

@sarah-witt sarah-witt changed the title Sarah/fix typos warn Properly create list of known options when detecting typos Feb 9, 2022
@sarah-witt sarah-witt marked this pull request as ready for review February 9, 2022 23:27
@sarah-witt sarah-witt requested review from a team as code owners February 9, 2022 23:27
Copy link
Contributor

@fanny-jiang fanny-jiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool!

datadog_checks_base/datadog_checks/base/checks/base.py Outdated Show resolved Hide resolved
@sarah-witt sarah-witt merged commit e925c60 into master Feb 11, 2022
@sarah-witt sarah-witt deleted the sarah/fix-typos-warn branch February 11, 2022 14:50
github-actions bot pushed a commit that referenced this pull request Feb 11, 2022
* Fix typo checking and update tests to use classes

* Style

* Revert style changes

* Add more type hints e925c60
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.

3 participants