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

Add type assertions of the functions in src/composer.jl. #153

Merged
merged 2 commits into from
Jun 16, 2024

Conversation

Paalon
Copy link
Contributor

@Paalon Paalon commented Jun 11, 2024

Original title: Refactor src/composer.jl

  • Add type assertions for all function arguments.
  • Remove redundant new lines.
  • Remove return at the end of the function.
  • Add new lines to decrease the number of characters per line.

Copy link

codecov bot commented Jun 11, 2024

Codecov Report

Attention: Patch coverage is 77.27273% with 5 lines in your changes missing coverage. Please review.

Project coverage is 86.29%. Comparing base (844ad27) to head (372ce95).
Report is 5 commits behind head on master.

Current head 372ce95 differs from pull request most recent head 14f1c4e

Please upload reports for the commit 14f1c4e to get more accurate results.

Files Patch % Lines
src/composer.jl 77.27% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #153      +/-   ##
==========================================
- Coverage   86.59%   86.29%   -0.31%     
==========================================
  Files          12       12              
  Lines        1626     1583      -43     
==========================================
- Hits         1408     1366      -42     
+ Misses        218      217       -1     

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

@Paalon
Copy link
Contributor Author

Paalon commented Jun 11, 2024

I formatted to my favorite style:

  • 4 spaces for 1 indent
  • if it's possible, the maximum number of characters per line is 92
  • no return at the end of function
  • if insert new lines in the arguments, split every arguments
  • if use if ... else ... end or open(...) do io ... end in a function definition, such functions should use function f(...) ... end syntax and not should use f(...) = ... syntax.
  • if a function definition is a simple value, use f(...) = ... syntax.
  • empty lines between top-level variables is 1
  • no space between default parameter: f(fruit=apple)
  • in type union with Nothing, place Nothing at second: Union{T, Nothing}

but it is not absolute.

@Paalon
Copy link
Contributor Author

Paalon commented Jun 11, 2024

I split this PR to type assertions and style formatting.

@Paalon
Copy link
Contributor Author

Paalon commented Jun 11, 2024

Now, this PR only includes type assertions.

@Paalon Paalon changed the title Refactor src/composer.jl. Add type assertions of the functions in src/composer.jl. Jun 11, 2024
Copy link
Collaborator

@kescobo kescobo left a comment

Choose a reason for hiding this comment

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

I'm certainly not against this in principle, but is there a compelling need for it? It does not (typically) improve speed, and in this case I think the argument names are pretty clear, so annotating them with types doesn't add much clarity.

I don't feel stongly, just something to consider.

@GunnarFarneback
Copy link
Contributor

It definitely won't make a difference to speed, but it adds a small amount of clarity and gives a faster error if you make a mistake when making code changes, so I think it's an improvement.

@Paalon
Copy link
Contributor Author

Paalon commented Jun 16, 2024

I think this can be safely merged. @kescobo Can you merge this?

@Paalon Paalon mentioned this pull request Jun 16, 2024
@kescobo kescobo merged commit f6185fa into JuliaData:master Jun 16, 2024
20 checks passed
@Paalon Paalon deleted the refactor-composer branch June 16, 2024 11:45
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