Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Issue #783 Fix all remaining MyPy errors #784

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

Merged
merged 17 commits into from
Jan 31, 2024
Merged

Issue #783 Fix all remaining MyPy errors #784

merged 17 commits into from
Jan 31, 2024

Conversation

Manangka
Copy link
Collaborator

@Manangka Manangka commented Jan 28, 2024

Fixes #783

This commit fixes all remaining MyPy errors in the mf6 module

The PR is split in several commits, each commit contains a certain file in which the mypy errors are fixes or exist of a type of error that crosses multiple files. I suggest reviewing this PR commit by commit.

Checklist

  • Links to correct issue
  • Update changelog, if changes affect users
  • PR title starts with Issue #nr, e.g. Issue #737
  • Unit tests were added
  • If feature added: Added/extended example

@Manangka Manangka force-pushed the issue_783_FixMyPy branch 2 times, most recently from a3a26f7 to 9d3f70b Compare January 29, 2024 11:55
@Manangka Manangka marked this pull request as ready for review January 29, 2024 13:13
Copy link
Contributor

@luitjansl luitjansl left a comment

Choose a reason for hiding this comment

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

looks good

def write(
self,
pkgname: str,
globaltimes: Union[List, np.ndarray],
Copy link
Contributor

Choose a reason for hiding this comment

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

can you specify that it must be a list of Datetimes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -333,6 +334,7 @@ def to_mf6_pkg(
top: GridDataArray,
bottom: GridDataArray,
k: GridDataArray,
validate: bool = False,
Copy link
Contributor

Choose a reason for hiding this comment

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

ïs this a mypy fix?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is part of the wel fix. I realized that the wel package is written the same was as the hfb package. I therefor written the write method of the wel package in the same way as the hfb package.

Except for the validate method. The wel package had a validate flag that the hfb was missing. By adding it to the hfb package both packages have the same kind of behavior and can be threaten the same

active, top, bottom, k, False, write_context.is_partitioned
)
mf6_pkg.write("packagename", globaltimes, write_context)
mf6_pkg.write("packagename", globaltimes, write_context)
Copy link
Contributor

Choose a reason for hiding this comment

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

why twice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ow that is a mistake.
Removed it

Copy link
Contributor

@JoerivanEngelen JoerivanEngelen left a comment

Choose a reason for hiding this comment

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

Looks good, some comments.

I see we use a mix of List as well as list. I see List and Dict are on the list of deprecated aliases since python 3.9, so we can replace them with list and dict respectively.

https://docs.python.org/3/library/typing.html#deprecated-aliases

validate: bool = True,
):
super().__init__()
self.dataset["cellid"] = cellid
self.dataset["rate"] = rate
self.dataset["save_flows"] = save_flows
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, related to this issue I think: #652

# Conflicts:
#	imod/mf6/buy.py
#	imod/mf6/dis.py
#	imod/mf6/mf6_wel_adapter.py
#	imod/mf6/regridding_utils.py
@Manangka
Copy link
Collaborator Author

Looks good, some comments.

I see we use a mix of List as well as list. I see List and Dict are on the list of deprecated aliases since python 3.9, so we can replace them with list and dict respectively.

https://docs.python.org/3/library/typing.html#deprecated-aliases

Replaced List/Dict by list/dict. There are other deprecated types but i consider it out of scope (mainly because it doesn't cause a mypy error with the current settings).

@Manangka Manangka added this pull request to the merge queue Jan 31, 2024
Merged via the queue into master with commit bbeab94 Jan 31, 2024
@Manangka Manangka deleted the issue_783_FixMyPy branch January 31, 2024 14:17
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.

Fix MyPy errors
3 participants