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 errors not TypeError #1388

Merged
merged 17 commits into from
Oct 9, 2023
Merged

Conversation

jonasdmarkussen
Copy link
Contributor

Description

Changed errortype from ValueError to TypeError on relevant places in 14 files.

Checklist:

  • Tests added/updated.
  • Documentation updated. Documentation is generated from docstrings - these must be updated according to your change.
    If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.
  • Changelog updated in CHANGELOG.md.
  • Version bumped. If triggering a new release is desired, bump the version number in _version.py and pyproject.toml per semantic versioning.

@jonasdmarkussen jonasdmarkussen requested review from a team as code owners September 29, 2023 09:47
Copy link
Collaborator

@erlendvollset erlendvollset left a comment

Choose a reason for hiding this comment

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

Invalid Literal values should raise ValueErrors

@jonasdmarkussen
Copy link
Contributor Author

Reverted some of the changes now @erlendvollset - if you want to take another look

@erlendvollset
Copy link
Collaborator

There are still a bunch of ValueErrors that have been changed to TypeErrors for invalid literal values.

Copy link
Contributor

@haakonvt haakonvt left a comment

Choose a reason for hiding this comment

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

You have found a lot of wrong exceptions, please re-open this PR 😄 (I commented on the three first, but there are several more!)

cognite/client/_api/raw.py Show resolved Hide resolved
cognite/client/_api/sequences.py Show resolved Hide resolved
@jonasdmarkussen
Copy link
Contributor Author

@haakonvt Updated now - hope I have got it (more) right this time 🥲


Returns:
int: The total number of datapoints
"""
if self.is_string:
raise ValueError("String time series does not support count aggregate.")
raise TypeError("String time series does not support count aggregate.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's go with RuntimeError instead

Copy link
Contributor

@haakonvt haakonvt left a comment

Choose a reason for hiding this comment

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

Lgtm! 🚀

@haakonvt
Copy link
Contributor

haakonvt commented Oct 6, 2023

@jonasdmarkussen A few tests that needs to be updated after the changes:

FAILED tests/tests_integration/test_api/test_time_series.py::TestTimeSeriesHelperMethods::test_get_count__string_fails - RuntimeError: String time series does not support count aggregate.
FAILED tests/tests_unit/test_api/test_raw.py::TestRawRows::test_list_cols_str_not_supported - TypeError: Expected a list for argument columns
FAILED tests/tests_unit/test_api/test_raw.py::TestRawRows::test_iter_cols_str_not_supported - TypeError: Expected a list for argument columns
FAILED tests/tests_unit/test_data_classes/test_time_series.py::TestTimeSeries::test_get_count__string_raises - RuntimeError: String time series does not support count aggregate.

@haakonvt haakonvt requested a review from erlendvollset October 9, 2023 19:06
@haakonvt haakonvt changed the title Changed from ValueError to TypeError on relevant places Fix type errors not TypeError Oct 9, 2023
@haakonvt haakonvt enabled auto-merge (squash) October 9, 2023 19:08
@codecov
Copy link

codecov bot commented Oct 9, 2023

Codecov Report

Merging #1388 (7ae74c4) into master (e058976) will decrease coverage by 0.02%.
The diff coverage is 28.57%.

@@            Coverage Diff             @@
##           master    #1388      +/-   ##
==========================================
- Coverage   90.70%   90.69%   -0.02%     
==========================================
  Files         119      119              
  Lines       14524    14524              
==========================================
- Hits        13174    13172       -2     
- Misses       1350     1352       +2     
Files Coverage Δ
cognite/client/_api/raw.py 95.97% <100.00%> (ø)
cognite/client/data_classes/time_series.py 95.00% <100.00%> (ø)
cognite/client/_api/data_modeling/instances.py 83.39% <0.00%> (ø)
cognite/client/_api/sequences.py 95.09% <0.00%> (ø)
cognite/client/utils/_auxiliary.py 90.90% <0.00%> (ø)
cognite/client/data_classes/data_modeling/ids.py 89.28% <0.00%> (ø)

... and 1 file with indirect coverage changes

Copy link
Collaborator

@erlendvollset erlendvollset left a comment

Choose a reason for hiding this comment

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

Lgtm 👌👌

@haakonvt haakonvt merged commit 707cf5d into master Oct 9, 2023
7 checks passed
@haakonvt haakonvt deleted the change-ValueError-to-TypeError branch October 9, 2023 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants