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

Use and apply black formatting #860

Open
wants to merge 63 commits into
base: dev
Choose a base branch
from
Open

Use and apply black formatting #860

wants to merge 63 commits into from

Conversation

rly
Copy link
Contributor

@rly rly commented May 11, 2023

Motivation

I added black to pre-commit so it will automatically modify the code to comply with black's uncompromising style guide.

In this PR, I made some manual adjustments, particularly to docval statements so that the arguments they are consistent. Note that this code:

@docval({"name": "key_name", "type": str, "doc": "The name of the key to be added."})

is kept as is by black. If we want to change that to:

@docval(
    {
        "name": "key_name",
        "type": str, 
        "doc": "The name of the key to be added.",
    }
)

then we need to add a comma at the end of the last element in the dictionary.

For us, I think we should keep the dict arguments within a single docval call consistent with each other. If all the dicts can fit on one line, then they should all be on one line. Otherwise, expand all the dicts to the second form above, which makes the arguments more readable in my opinon, because it is easier to see the parallelism of the arguments.

See also #844.

How to test the behavior?

Show how to reproduce the new behavior (can be a bug fix or a new feature)

Checklist

  • Did you update CHANGELOG.md with your changes?
  • Have you checked our Contributing document?
  • Have you ensured the PR clearly describes the problem and the solution?
  • Is your contribution compliant with our coding style? This can be checked running flake8 from the source directory.
  • Have you checked to ensure that there aren't other open Pull Requests for the same change?
  • Have you included the relevant issue number using "Fix #XXX" notation where XXX is the issue number? By including "Fix #XXX" you allow GitHub to close issue #XXX when the PR is merged.

@rly rly added category: enhancement improvements of code or code behavior priority: low alternative solution already working and/or relevant to only specific user(s) labels May 11, 2023
@codecov
Copy link

codecov bot commented May 11, 2023

Codecov Report

Patch coverage: 90.30% and no project coverage change.

Comparison is base (f81537c) 88.19% compared to head (f85165d) 88.20%.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #860   +/-   ##
=======================================
  Coverage   88.19%   88.20%           
=======================================
  Files          44       44           
  Lines        9022     9029    +7     
  Branches     2577     2577           
=======================================
+ Hits         7957     7964    +7     
  Misses        753      753           
  Partials      312      312           
Impacted Files Coverage Δ
src/hdmf/backends/warnings.py 100.00% <ø> (ø)
src/hdmf/build/map.py 0.00% <0.00%> (ø)
src/hdmf/build/warnings.py 100.00% <ø> (ø)
src/hdmf/monitor.py 0.00% <0.00%> (ø)
src/hdmf/region.py 50.00% <33.33%> (ø)
src/hdmf/array.py 52.55% <66.66%> (ø)
src/hdmf/validate/validator.py 84.02% <73.77%> (-0.08%) ⬇️
src/hdmf/query.py 62.50% <77.77%> (ø)
src/hdmf/validate/errors.py 86.60% <78.37%> (ø)
src/hdmf/backends/hdf5/h5tools.py 82.36% <82.72%> (ø)
... and 31 more

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@bendichter
Copy link
Contributor

@rly I'm OK with either: basing the format of the docval calls on line length alone or forcing regularity. I think the way you have chosen is perfectly fine. I was not aware of the trailing comma feature of Black, but sure enough it's a feature of the package. source

@oruebel
Copy link
Contributor

oruebel commented May 11, 2023

or us, I think we should keep the dict arguments within a single docval call consistent with each other. If all the dicts can fit on one line, then they should all be on one line. Otherwise, expand all the dicts to the second form above

That sounds good to me too

@rly rly marked this pull request as ready for review May 12, 2023 17:17
@rly rly requested review from oruebel, mavaylon1 and bendichter and removed request for oruebel May 12, 2023 17:17
bendichter
bendichter previously approved these changes Jun 16, 2023
@bendichter
Copy link
Contributor

@rly are we good to merge this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: enhancement improvements of code or code behavior priority: low alternative solution already working and/or relevant to only specific user(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants