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

Type check ert.gui #8160

Merged
merged 2 commits into from
Jun 24, 2024
Merged

Conversation

eivindjahren
Copy link
Contributor

@eivindjahren eivindjahren commented Jun 17, 2024

  • PR title captures the intent of the changes, and is fitting for release notes.
  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.
  • Make sure tests pass locally (after every commit!)

When applicable

  • When there are user facing changes: Updated documentation
  • New behavior or changes to existing untested code: Ensured that unit tests are added (See Ground Rules).
  • Large PR: Prepare changes in small commits for more convenient review
  • Bug fix: Add regression test for the bug
  • Bug fix: Create Backport PR to latest release

@eivindjahren eivindjahren marked this pull request as draft June 17, 2024 06:57
@eivindjahren eivindjahren force-pushed the type_check_ertwidgets branch 2 times, most recently from c58acf6 to faeebf8 Compare June 17, 2024 11:10
@eivindjahren eivindjahren changed the title Type check ert.gui.ertwidgets Type check ert.gui Jun 17, 2024
@eivindjahren eivindjahren force-pushed the type_check_ertwidgets branch 11 times, most recently from 84ac680 to 3ce383f Compare June 20, 2024 08:31
@eivindjahren eivindjahren marked this pull request as ready for review June 20, 2024 09:37
@eivindjahren eivindjahren added the release-notes:skip If there should be no mention of this in release notes label Jun 20, 2024
@equinor equinor deleted a comment from codecov-commenter Jun 20, 2024
@eivindjahren eivindjahren force-pushed the type_check_ertwidgets branch 2 times, most recently from 2c764b7 to 44ff307 Compare June 24, 2024 04:43
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 79.95227% with 84 lines in your changes missing coverage. Please review.

Project coverage is 87.11%. Comparing base (67b0e46) to head (44ff307).

Files Patch % Lines
src/ert/gui/ertwidgets/listeditbox.py 40.00% 12 Missing ⚠️
src/ert/gui/tools/workflows/run_workflow_widget.py 50.00% 12 Missing ⚠️
src/ert/gui/simulation/view/update.py 37.50% 10 Missing ⚠️
.../ert/gui/tools/plot/widgets/clearable_line_edit.py 52.63% 9 Missing ⚠️
src/ert/gui/tools/file/file_dialog.py 55.55% 8 Missing ⚠️
...t/gui/tools/plot/plot_ensemble_selection_widget.py 76.92% 6 Missing ⚠️
src/ert/gui/simulation/run_dialog.py 82.75% 5 Missing ⚠️
src/ert/gui/tools/plot/plot_window.py 63.63% 4 Missing ⚠️
src/ert/gui/tools/plugins/process_job_dialog.py 60.00% 4 Missing ⚠️
src/ert/gui/simulation/view/realization.py 86.36% 3 Missing ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8160      +/-   ##
==========================================
- Coverage   87.18%   87.11%   -0.07%     
==========================================
  Files         381      381              
  Lines       23669    23757      +88     
  Branches      619      630      +11     
==========================================
+ Hits        20635    20696      +61     
- Misses       2953     2988      +35     
+ Partials       81       73       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +92 to +97
def setText(self, a0: Optional[str]) -> None:
self.hidePlaceHolder()

QLineEdit.setText(self, string)
QLineEdit.setText(self, a0)

if len(str(string)) == 0 and not self.hasFocus():
if len(str(a0)) == 0 and not self.hasFocus():
Copy link
Contributor

@andreas-el andreas-el Jun 24, 2024

Choose a reason for hiding this comment

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

Should this have been 'text' instead, since this is not an event?
text : Optional[str]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The setText function in QLineEdit names the first parameter a0 and sets the type to Optional[str], so that is what we have to use.

Comment on lines +64 to +65
if (viewport := self.viewport()) is not None:
viewport.setMouseTracking(True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the walrus operator here? We don't need viewport later on?

if self.viewport():
    self.viewport().setMouseTracking(True)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because two calls to self.viewport() could first return None and then something else. We kind of know this is a getter, but mypy doesn't care.

Comment on lines +104 to +105
if self._running_workflow_dialog is not None:
self._running_workflow_dialog.disableCloseButton()
Copy link
Contributor

Choose a reason for hiding this comment

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

More compact?

if self._running_workflow_dialog:
    self._running_workflow_dialog.disableCloseButton()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe, but I think its best to avoid messing with __bool__ for now.


def runWorkflow(self) -> None:
assert self._workflow_runner is not None
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not assert it simply? Is that not the same?

assert self._workflow_runner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just in case __bool__ is overriden somewhere, I would prefer to keep it the way it is.

Comment on lines +50 to +52
horizontal_header = self.horizontalHeader()
assert horizontal_header is not None
horizontal_header.setSectionResizeMode(QHeaderView.ResizeToContents)
Copy link
Contributor

Choose a reason for hiding this comment

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

why save this as a variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So that we can assert that it is None. Although self.horizontlHeader() is intented to be a property, it is called as a function so two subsequent calls could first return the horizontal header and next return None.

Copy link
Contributor

@andreas-el andreas-el left a comment

Choose a reason for hiding this comment

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

Need slight changes, but great work! 🎉

@eivindjahren eivindjahren force-pushed the type_check_ertwidgets branch 3 times, most recently from a6d81f7 to 093c501 Compare June 24, 2024 11:53
@eivindjahren eivindjahren force-pushed the type_check_ertwidgets branch from 093c501 to a70084c Compare June 24, 2024 12:02
Copy link
Contributor

@andreas-el andreas-el left a comment

Choose a reason for hiding this comment

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

Mighty fine sir! 🎩

@eivindjahren eivindjahren force-pushed the type_check_ertwidgets branch from a70084c to e4bcfbb Compare June 24, 2024 12:08
@eivindjahren eivindjahren enabled auto-merge (squash) June 24, 2024 12:09
@eivindjahren eivindjahren disabled auto-merge June 24, 2024 12:09
@eivindjahren eivindjahren enabled auto-merge (squash) June 24, 2024 12:09
@eivindjahren eivindjahren merged commit 839a23b into equinor:main Jun 24, 2024
38 checks passed
@eivindjahren eivindjahren deleted the type_check_ertwidgets branch June 25, 2024 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes:skip If there should be no mention of this in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants