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

Remove star-imports #19

Merged
merged 2 commits into from
Nov 21, 2023
Merged

Remove star-imports #19

merged 2 commits into from
Nov 21, 2023

Conversation

akx
Copy link
Contributor

@akx akx commented Feb 8, 2023

The liberal use of star-imports makes miditoolkit export quite a lot of names that probably shouldn't be.

>>> import miditoolkit as m
>>> dir(m)
['BLACK_KEY_SATUR', 
 'CHROMA_CMAP', 
 'ControlChange', 
 'DEFAULT_BPM', 
 'Instrument', 
 'KeySignature', 
 'Lyric', 
 'Marker', 
 'MidiFile', 
 'NOTE_CMAP', 
 'Note', 
 'OFFSET_OCTAVE', 
 'PITCH_RANGE', 
 'PITCH_TO_NAME', 
 'PR_CMAP', 
 'Pedal', 
 'PitchBend', 
 'SM_CMAP', 
 'TempoChange', 
 'TimeSignature', 
 'WHITE_KEY_SATUR', 
 'XLABEL_FONT_SIZE', 
 'YLABEL_FONT_SIZE', 
 '__builtins__', 
 '__cached__', 
 '__doc__', 
 '__file__', 
 '__loader__', 
 '__name__', 
 '__package__', 
 '__path__', 
 '__spec__', 
 '__version__', 
 'collections', 
 'containers', 
 'csc_matrix', 
 'ct', 
 'deepcopy', 
 'downsample', 
 'example_midi_file', 
 'functools', 
 'matplotlib', 
 'midi', 
 'mido', 
 'normalize', 
 'notes2pianoroll', 
 'np', 
 'os', 
 'parser', 
 'pianoroll', 
 'pianoroll2notes', 
 'pitch_padding', 
 'plot', 
 'plot_background', 
 'plot_chroma', 
 'plot_grid', 
 'plot_heatmap', 
 'plot_note_entries', 
 'plot_xticks', 
 'plot_yticks', 
 'plt', 
 'pylab', 
 're', 
 'tochroma', 
 'utils', 
 'vis', 
 'warnings']

This removes all of the star imports (so this is a semver major change) in favor of just regular imports from the respective modules.

Copy link
Collaborator

@Natooz Natooz left a comment

Choose a reason for hiding this comment

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

Hello 👋
Thank you for the suggestion, and sorry for the late reply, the repo has been idle for some time, I'm currently fixing and improving things here.
I agree with you that star import should be removed.
Here however I thing it would still make sens and be convenient to directly access to the MidiFile and container (Note, ...) classes directly from the main module.

Would you still be interested in applying these last changes, and solve the branch conflicts that appeared as some changes has been made since?
This should hopefully be featured in the next release.

README.md Outdated Show resolved Hide resolved
miditoolkit/midi/__init__.py Show resolved Hide resolved
miditoolkit/midi/__init__.py Show resolved Hide resolved
miditoolkit/__init__.py Show resolved Hide resolved
@akx

This comment was marked as outdated.

@akx akx requested a review from Natooz November 21, 2023 12:36
@akx
Copy link
Contributor Author

akx commented Nov 21, 2023

@Natooz Rebased, added exports for MidiFile and all of the classes from containers. Will fix the tests...

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4f94fbd) 62.23% compared to head (b467678) 58.34%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #19      +/-   ##
==========================================
- Coverage   62.23%   58.34%   -3.89%     
==========================================
  Files          13       12       -1     
  Lines         789      785       -4     
==========================================
- Hits          491      458      -33     
- Misses        298      327      +29     

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

Copy link
Collaborator

@Natooz Natooz left a comment

Choose a reason for hiding this comment

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

Wonderful thank you, everything seems good + tests are passing!

@Natooz Natooz merged commit c4b9d2e into YatingMusic:master Nov 21, 2023
15 checks passed
@akx akx deleted the no-star-imports branch November 21, 2023 13:29
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