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

calrify type of pitch constructor argument #1746

Merged
merged 4 commits into from
Feb 7, 2025

Conversation

float3
Copy link
Contributor

@float3 float3 commented Jan 31, 2025

Line 1926 says that the argument can be a Pitch too so the constructor should reflect that

@mscuthbert
Copy link
Member

Hi @float3 (hill) thanks for the PR -- it's nearly perfect for what we should have here given the code

I'm leaning instead though to removing the line -- it comes form a type of coding paradigm in 2014 that I don't think we would do today (from before Typed python and automatic code generation). I think that we're better off getting rid of it once I see if it's used anywhere in music21 -- the whole test suite passes so I think not.

So I want to thank you for the PR but I think we'll go in the opposite direction and trust the Docs and change the code to match)

There's also a bug in the code for documenting Pitch as acceptable to __init__. Here it will fail:

class Pitch2(pitch.Pitch): pass

p = pitch.Pitch('C4')
Pitch2(p)   # will raise error

we did not check isinstance(name, pitchPitch) instead matched by type(self), so the docs would still be incorrect!

I think for that reason better to get rid of it. Will make creating pitches a few ms faster which is always appreciated.

Will leave open for a day or two to see if there are any objections to this approach.

@float3
Copy link
Contributor Author

float3 commented Feb 6, 2025

I see, I've adjusted the PR, thanks for your response

Copy link
Member

@mscuthbert mscuthbert left a comment

Choose a reason for hiding this comment

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

Approved!

float3 and others added 3 commits February 6, 2025 20:25
My guess is that the line was the way it was because it's called with a mixture of strings and Pitch objects.
@mscuthbert mscuthbert closed this Feb 7, 2025
@mscuthbert mscuthbert reopened this Feb 7, 2025
@mscuthbert
Copy link
Member

Some mypy errors were from updating mypy and unrelated. Fixed in #1747

@mscuthbert mscuthbert merged commit 6c74d50 into cuthbertLab:master Feb 7, 2025
14 of 15 checks passed
@mscuthbert
Copy link
Member

Thank you -- congrats on your first commit to music21! :-) The community will long be grateful!

@coveralls
Copy link

Coverage Status

Changes unknown
when pulling b4afaa4 on float3:patch-1
into ** on cuthbertLab:master**.

@float3
Copy link
Contributor Author

float3 commented Feb 7, 2025

Thank you -- congrats on your first commit to music21! :-) The community will long be grateful!

thank you and thank you for music21! hope to contribute again if I find anything else

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