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

796 always return #953

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

clizbe
Copy link
Member

@clizbe clizbe commented Dec 6, 2024

Related issues

Closes #796
Closes #940

Checklist

  • I am following the contributing guidelines

  • Tests are passing

  • Lint workflow is passing

  • Docs were updated and workflow is passing

@clizbe
Copy link
Member Author

clizbe commented Dec 6, 2024

I'm not sure all the files should be changed with adding 'return.'
I ran JuliaFormatter using format(".") which might touch files we don't normally format.

@@ -441,8 +442,7 @@ See the file <benchmark/profiling.jl> for an example of profiling code.
When publishing a new version of the model to the Julia Registry, follow this procedure:

> **Note:**
> To be able to register, you need to be a member of the organisation TulipaEnergy and have your visibility set to public:<br>
> ![Screenshot of public members of TulipaEnergy on GitHub](./images/PublicMember.png)
> To be able to register, you need to be a member of the organisation TulipaEnergy and have your visibility set to public:<br> > ![Screenshot of public members of TulipaEnergy on GitHub](./images/PublicMember.png)
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure why this changed.

@@ -19,7 +19,7 @@ function add_consumer_constraints!(model, constraints, graph, sets)

# - Balance constraint (using the lowest temporal resolution)
df = filter(:asset => ∈(Ac), constraints[:highest_in_out].indices; view = true)
model[:consumer_balance] = [
return model[:consumer_balance] = [
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if this is correct or these should all be return nothing.

Copy link
Member

Choose a reason for hiding this comment

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

The JuliaFormatter is technically correct, because these were indeed being returned implicitly. But we don't expect any return, so adding an empty return after this is better, in my opinion

@clizbe clizbe requested a review from abelsiqueira December 6, 2024 15:38
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.50%. Comparing base (9233ff4) to head (c410531).

Files with missing lines Patch % Lines
src/io.jl 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #953   +/-   ##
=======================================
  Coverage   95.50%   95.50%           
=======================================
  Files          30       30           
  Lines        1045     1045           
=======================================
  Hits          998      998           
  Misses         47       47           

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

@@ -198,6 +198,7 @@ We will try to follow these during development and reviews.
- List obvious objects, e.g., `using JuMP: @variable`, since `@variable` is obviously from JuMP in this context, or `using Graph: SimpleDiGraph`, because it's a constructor with an obvious name.
- For other objects inside `Package`, use `using Package: Package` and explicitly call `Package.A` to use it, e.g., `DataFrames.groupby`.
- List all `using` in <src/TulipaEnergyModel.jl>.
- Explicitly state what a function will `return`, including `return nothing`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Explicitly state what a function will `return`, including `return nothing`.
- Explicitly state what a function will `return`, including `return nothing`.

@abelsiqueira
Copy link
Member

Indeed, many places will be changed with this new rule because all functions return something (implicit rule is to return the last thing in a function). This is annoying, but necessary with this change. For most places, we are going to need manual intervention to add and empty return before the end to reflect the desired behaviour (assuming the desired behaviour is to return nothing for functions that are not expected to return anything)

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.

Update JuliaFormater options Add formatter option to have explicit returns
2 participants