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

Keywords need to be part of the function signature #839

Closed
mscuthbert opened this issue Feb 8, 2021 · 0 comments · Fixed by #1377
Closed

Keywords need to be part of the function signature #839

mscuthbert opened this issue Feb 8, 2021 · 0 comments · Fixed by #1377
Milestone

Comments

@mscuthbert
Copy link
Member

mscuthbert commented Feb 8, 2021

It's time to stop creating methods and classes like this:

def __init__(self, **keywords):
     if 'hello' in keywords:
         hello = keywords['hello']
     else:
         hello = 'hi'

All the keywords expected by a method should be in the function signature:

def __init__(self, *, hello='hi'):

It's still okay to allow a generic **keywords argument, if the class is expected to be subclassed by something with more keywords or if it calls a subfunction that might have more keywords:

def __init__(self, *, hello='hi', **keywords):
      super().__init__(**keywords)
      self.hello = hello

But it's not at all apparent to a user what is possible with **keywords in the current state.

Do this before (or start it) as part of #763 show implementation.

@mscuthbert mscuthbert added this to the v7 milestone Feb 8, 2021
mscuthbert added a commit that referenced this issue Aug 14, 2022
Fixes #839

Each push will include one or more modules.

Starting with Base.
mscuthbert added a commit that referenced this issue Aug 17, 2022
Fixes #839

Misc fixes:
* Metadata date formats derive from DatePrimitive not DateSingle (attn: @gregchapman-dev)
* remove unused note.linkage
* kwargs -> keywords throughout
* fix metadata tests pinned to 8.0.0a9

Modules/Classes affected include:

* base
* Tuplet
* note
* Stream
* chordBase
* discrete analysis
* Variant (now takes only one arg)
* midi realtime, etc.
* Chorales, Date primitives, RepeatBracket
* layout
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 a pull request may close this issue.

1 participant