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

Change default arg from False to None in the setup run dir #135

Merged
merged 2 commits into from
Mar 29, 2024

Conversation

ashjbarnes
Copy link
Collaborator

PR closes issue #134

@ashjbarnes ashjbarnes requested a review from navidcy March 28, 2024 10:17
@navidcy navidcy requested a review from angus-g March 28, 2024 10:55
Co-authored-by: Navid C. Constantinou <[email protected]>
Copy link
Contributor

@navidcy navidcy left a comment

Choose a reason for hiding this comment

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

lgtm

@navidcy navidcy merged commit a364cec into main Mar 29, 2024
5 checks passed
@navidcy navidcy deleted the nonetype_arg_for_setupfunction branch March 29, 2024 05:16
@@ -1470,14 +1470,15 @@ def setup_run_directory(
raise ValueError(
f"Cannot find the premade run directory files at \n{premade_rundir_path}\n. Something is not right about how the package has been installed as these files are missing!"
)
if surface_forcing != False:
if type(surface_forcing) == str:
Copy link
Collaborator

Choose a reason for hiding this comment

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

isinstance(surface_forcing, str)... or just if surface_forcing now, maybe use type hint of Optional[str] to suggest what is expected. Anyway, guess it's too late :)

Copy link
Contributor

Choose a reason for hiding this comment

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

it's never too late, we can open another one ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand your second suggestion, after "or just"... though

Copy link
Contributor

Choose a reason for hiding this comment

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

oh... now I see... I didn't know that if x: would be triggered even if x is not a boolean or 1.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the context of Boolean operations, and also when expressions are used by control flow statements, the following values are interpreted as false: False, None, numeric zero of all types, and empty strings and containers (including strings, tuples, lists, dictionaries, sets and frozensets). All other values are interpreted as true.

From https://docs.python.org/3/reference/expressions.html#booleans

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