Skip to content
Snippets Groups Projects

Apply Flake8, YamlLint and Black styling to entire repository

Merged Daniel Thomas Murnane requested to merge DM_fix_linting into dev
1 unresolved thread

This is a big merge, but it is purely aesthetic! It simply applies Flake8 and Black styling to every file. It is compatible with the pre-commit hooks that we encourage people to use when git committing.

It passes all linting checks, build check, and pytest checks.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Daniel Thomas Murnane requested review from @xju and @scaillou

    requested review from @xju and @scaillou

    • It is great! Thanks for putting them together.

      One comment, maybe for the next merge request, but I want to express it now, is that some configuration parameters are optional, and some are mandatory. We use the assert statement pervasively to check that only when we want to use the parameters; therefore, such checks of a parameter come along with the function that wants to use the parameter. It can happen that the same parameter may be checked by a few functions. It looks tedious to me.

      I suggest we check the configuration at the class constructor, __init__(), possibly raise an error when the check fails, and document the list of parameters in the class docstring. Developers and users will know exactly what parameters are mandatory and what are optional for the class.

      Specifically, for optional parameters, we assign None or reasonable default values; for mandatory parameters, we assign reasonable default values or raise a RunTimeError only when needed. In this way, the self.hparams always exists and contains all parameters needed in the class with reasonable default values, including None. It will save us from checking the configuration in a function that does the actual work, like:

              if (
                  self.hparams is not None
                  and "hard_cuts" in self.hparams.keys()
                  and self.hparams["hard_cuts"]
              ):
                  assert isinstance(
                      self.hparams["hard_cuts"], dict
                  ), "Hard cuts must be a dictionary"
                  handle_hard_cuts(event, self.hparams["hard_cuts"])
    • Totally agree. I've just added an issue to solve this exact problem.

    • Please register or sign in to reply
  • mentioned in issue #29

  • Cool. Assuming this looks good, I'll merge it in (along with the related pytest and coverage PR).

    Let's address the default and documented hparams issue in a future PR.

  • mentioned in commit 5c7eaac0

Please register or sign in to reply
Loading