From 15595892ec87eff987be7d1b2f0fc606de0de010 Mon Sep 17 00:00:00 2001 From: dtomlinson Date: Mon, 9 Mar 2020 01:30:50 +0000 Subject: [PATCH 1/3] updating docstring --- src/musicbrainzapi/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/musicbrainzapi/__init__.py b/src/musicbrainzapi/__init__.py index e69de29..f979127 100644 --- a/src/musicbrainzapi/__init__.py +++ b/src/musicbrainzapi/__init__.py @@ -0,0 +1,7 @@ +""" +musicbrainzapi: A CLI lyrics searcher +===================================== + +This module was written by dtomlinson for Aire Logic + +""" From ed9a30db138ba9da38b9ca425e4005e4999f1746 Mon Sep 17 00:00:00 2001 From: dtomlinson Date: Mon, 9 Mar 2020 01:47:16 +0000 Subject: [PATCH 2/3] code quality fixes --- Dockerfile | 3 ++- setup.py | 1 - src/musicbrainzapi/api/lyrics/builder.py | 12 ++++++------ src/musicbrainzapi/api/lyrics/director.py | 2 -- src/musicbrainzapi/cli/cli.py | 6 +++--- src/musicbrainzapi/wordcloud/__init__.py | 12 ++++++------ tests/test_musicbrainzapi.py | 5 ----- 7 files changed, 17 insertions(+), 24 deletions(-) delete mode 100644 tests/test_musicbrainzapi.py diff --git a/Dockerfile b/Dockerfile index 4d0c493..ece1932 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,4 +5,5 @@ RUN mkdir /outputs && mkdir /inputs COPY ./setup.py /inputs/setup.py COPY ./src /inputs/src -RUN cd /inputs && python ./setup.py install +WORKDIR /inputs +RUN python ./setup.py install diff --git a/setup.py b/setup.py index a22e5f6..b7db22c 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,6 @@ setup_kwargs = { 'author_email': 'dtomlinson@panaetius.co.uk', 'maintainer': None, 'maintainer_email': None, - 'url': None, 'url': 'https://github.com/dtomlinson91/musicbrainzapi-cv-airelogic', 'package_dir': package_dir, 'packages': packages, diff --git a/src/musicbrainzapi/api/lyrics/builder.py b/src/musicbrainzapi/api/lyrics/builder.py index 0eb2be8..25b3857 100644 --- a/src/musicbrainzapi/api/lyrics/builder.py +++ b/src/musicbrainzapi/api/lyrics/builder.py @@ -170,8 +170,8 @@ class LyricsBuilder(LyricsConcreteBuilder): avg = math.ceil(np.mean(nums)) median = math.ceil(np.median(nums)) std = math.ceil(np.std(nums)) - max = math.ceil(np.max(nums)) - min = math.ceil(np.min(nums)) + _max = math.ceil(np.max(nums)) + _min = math.ceil(np.min(nums)) p_10 = math.ceil(np.percentile(nums, 10)) p_25 = math.ceil(np.percentile(nums, 25)) p_75 = math.ceil(np.percentile(nums, 75)) @@ -181,8 +181,8 @@ class LyricsBuilder(LyricsConcreteBuilder): ('avg', avg), ('median', median), ('std', std), - ('max', max), - ('min', min), + ('max', _max), + ('min', _min), ('p_10', p_10), ('p_25', p_25), ('p_75', p_75), @@ -312,10 +312,10 @@ class LyricsBuilder(LyricsConcreteBuilder): f'{self.artist}' ), ) as bar: - for id, alb in self.release_group_ids.items(): + for _id, alb in self.release_group_ids.items(): resp_0 = addict.Dict( musicbrainzngs.browse_releases( - release_group=id, + release_group=_id, release_type=['album'], includes=['recordings'], limit=100, diff --git a/src/musicbrainzapi/api/lyrics/director.py b/src/musicbrainzapi/api/lyrics/director.py index d80da30..8bf41cb 100644 --- a/src/musicbrainzapi/api/lyrics/director.py +++ b/src/musicbrainzapi/api/lyrics/director.py @@ -1,6 +1,4 @@ from __future__ import annotations -import json -import os import click diff --git a/src/musicbrainzapi/cli/cli.py b/src/musicbrainzapi/cli/cli.py index 43c2d9f..e47a84a 100644 --- a/src/musicbrainzapi/cli/cli.py +++ b/src/musicbrainzapi/cli/cli.py @@ -30,9 +30,9 @@ class ComplexCLI(click.MultiCommand): rv.sort() return rv - def get_command(self, ctx, name): - mod = import_module(f'musicbrainzapi.cli.commands.cmd_{name}') - return getattr(mod, name) + def get_command(self, ctx, cmd_name): + mod = import_module(f'musicbrainzapi.cli.commands.cmd_{cmd_name}') + return getattr(mod, cmd_name) @click.command(cls=ComplexCLI, context_settings=CONTEXT_SETTINGS) diff --git a/src/musicbrainzapi/wordcloud/__init__.py b/src/musicbrainzapi/wordcloud/__init__.py index 384ff32..5b1a708 100644 --- a/src/musicbrainzapi/wordcloud/__init__.py +++ b/src/musicbrainzapi/wordcloud/__init__.py @@ -56,7 +56,7 @@ class LyricsWordcloud: cls, all_albums_lyrics_count: 'Lyrics.all_albums_lyrics_count', ) -> LyricsWordcloud: """Class method to instantiate with a microphone base image. - + Parameters ---------- all_albums_lyrics_count : Lyrics.all_albums_lyrics_count @@ -87,7 +87,7 @@ class LyricsWordcloud: """ self.lyrics_list = list() for i in self.all_albums_lyrics_count: - for album, lyric in i.items(): + for _, lyric in i.items(): for track in lyric: try: for word in track: @@ -141,10 +141,10 @@ class LyricsWordcloud: plt.axis('off') return self - def show_word_cloud(self): - """Shows the word cloud. - """ - plt.show() + # def show_word_cloud(self): + # """Shows the word cloud. + # """ + # plt.show() def create_word_cloud(self) -> None: """Creates a word cloud diff --git a/tests/test_musicbrainzapi.py b/tests/test_musicbrainzapi.py deleted file mode 100644 index 0f7eafd..0000000 --- a/tests/test_musicbrainzapi.py +++ /dev/null @@ -1,5 +0,0 @@ -from musicbrainzapi import __version__ - - -def test_version(): - assert __version__ == '0.1.0' From 237be15ecdce0f94b2b8259dfd9a0bfd47d1f437 Mon Sep 17 00:00:00 2001 From: dtomlinson Date: Mon, 9 Mar 2020 01:59:38 +0000 Subject: [PATCH 3/3] updating readme and adding coverage --- README.rst | 1 + poetry.lock | 46 +++++++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 9d45835..e889cde 100644 --- a/README.rst +++ b/README.rst @@ -10,6 +10,7 @@ Introduction .. image:: https://img.shields.io/github/languages/code-size/dtomlinson91/musicbrainzapi-cv-airelogic?style=for-the-badge .. image:: https://img.shields.io/github/languages/top/dtomlinson91/musicbrainzapi-cv-airelogic?style=for-the-badge .. image:: https://img.shields.io/requires/github/dtomlinson91/musicbrainzapi-cv-airelogic?style=for-the-badge +.. image:: https://img.shields.io/codacy/grade/f9517450400d48b0a7222a383c2e8fe2?style=for-the-badge Summary ======== diff --git a/poetry.lock b/poetry.lock index 490a5f5..0fae66f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -128,6 +128,17 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" version = "0.4.3" +[[package]] +category = "dev" +description = "Code coverage measurement for Python" +name = "coverage" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" +version = "5.0.3" + +[package.extras] +toml = ["toml"] + [[package]] category = "main" description = "Composable style cycles" @@ -784,7 +795,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] testing = ["jaraco.itertools", "func-timeout"] [metadata] -content-hash = "c39a5b0162f2941acee38685feb99d3b417a277744f8b74339775ee621d81872" +content-hash = "6731dc2e0e02c3693160c1be0ffa007ff49972bf424aa6968a14178f9ef39e9a" python-versions = "^3.7" [metadata.files] @@ -839,6 +850,39 @@ colorama = [ {file = "colorama-0.4.3-py2.py3-none-any.whl", hash = "sha256:7d73d2a99753107a36ac6b455ee49046802e59d9d076ef8e47b61499fa29afff"}, {file = "colorama-0.4.3.tar.gz", hash = "sha256:e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"}, ] +coverage = [ + {file = "coverage-5.0.3-cp27-cp27m-macosx_10_12_x86_64.whl", hash = "sha256:cc1109f54a14d940b8512ee9f1c3975c181bbb200306c6d8b87d93376538782f"}, + {file = "coverage-5.0.3-cp27-cp27m-macosx_10_13_intel.whl", hash = "sha256:be18f4ae5a9e46edae3f329de2191747966a34a3d93046dbdf897319923923bc"}, + {file = "coverage-5.0.3-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:3230d1003eec018ad4a472d254991e34241e0bbd513e97a29727c7c2f637bd2a"}, + {file = "coverage-5.0.3-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:e69215621707119c6baf99bda014a45b999d37602cb7043d943c76a59b05bf52"}, + {file = "coverage-5.0.3-cp27-cp27m-win32.whl", hash = "sha256:1daa3eceed220f9fdb80d5ff950dd95112cd27f70d004c7918ca6dfc6c47054c"}, + {file = "coverage-5.0.3-cp27-cp27m-win_amd64.whl", hash = "sha256:51bc7710b13a2ae0c726f69756cf7ffd4362f4ac36546e243136187cfcc8aa73"}, + {file = "coverage-5.0.3-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:9bea19ac2f08672636350f203db89382121c9c2ade85d945953ef3c8cf9d2a68"}, + {file = "coverage-5.0.3-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:5012d3b8d5a500834783689a5d2292fe06ec75dc86ee1ccdad04b6f5bf231691"}, + {file = "coverage-5.0.3-cp35-cp35m-macosx_10_12_x86_64.whl", hash = "sha256:d513cc3db248e566e07a0da99c230aca3556d9b09ed02f420664e2da97eac301"}, + {file = "coverage-5.0.3-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:3dbb72eaeea5763676a1a1efd9b427a048c97c39ed92e13336e726117d0b72bf"}, + {file = "coverage-5.0.3-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:15cf13a6896048d6d947bf7d222f36e4809ab926894beb748fc9caa14605d9c3"}, + {file = "coverage-5.0.3-cp35-cp35m-win32.whl", hash = "sha256:fca1669d464f0c9831fd10be2eef6b86f5ebd76c724d1e0706ebdff86bb4adf0"}, + {file = "coverage-5.0.3-cp35-cp35m-win_amd64.whl", hash = "sha256:1e44a022500d944d42f94df76727ba3fc0a5c0b672c358b61067abb88caee7a0"}, + {file = "coverage-5.0.3-cp36-cp36m-macosx_10_13_x86_64.whl", hash = "sha256:b26aaf69713e5674efbde4d728fb7124e429c9466aeaf5f4a7e9e699b12c9fe2"}, + {file = "coverage-5.0.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:722e4557c8039aad9592c6a4213db75da08c2cd9945320220634f637251c3894"}, + {file = "coverage-5.0.3-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:7afad9835e7a651d3551eab18cbc0fdb888f0a6136169fbef0662d9cdc9987cf"}, + {file = "coverage-5.0.3-cp36-cp36m-win32.whl", hash = "sha256:25dbf1110d70bab68a74b4b9d74f30e99b177cde3388e07cc7272f2168bd1477"}, + {file = "coverage-5.0.3-cp36-cp36m-win_amd64.whl", hash = "sha256:c312e57847db2526bc92b9bfa78266bfbaabac3fdcd751df4d062cd4c23e46dc"}, + {file = "coverage-5.0.3-cp37-cp37m-macosx_10_13_x86_64.whl", hash = "sha256:a8b8ac7876bc3598e43e2603f772d2353d9931709345ad6c1149009fd1bc81b8"}, + {file = "coverage-5.0.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:527b4f316e6bf7755082a783726da20671a0cc388b786a64417780b90565b987"}, + {file = "coverage-5.0.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:d649dc0bcace6fcdb446ae02b98798a856593b19b637c1b9af8edadf2b150bea"}, + {file = "coverage-5.0.3-cp37-cp37m-win32.whl", hash = "sha256:cd60f507c125ac0ad83f05803063bed27e50fa903b9c2cfee3f8a6867ca600fc"}, + {file = "coverage-5.0.3-cp37-cp37m-win_amd64.whl", hash = "sha256:c60097190fe9dc2b329a0eb03393e2e0829156a589bd732e70794c0dd804258e"}, + {file = "coverage-5.0.3-cp38-cp38-macosx_10_13_x86_64.whl", hash = "sha256:d7008a6796095a79544f4da1ee49418901961c97ca9e9d44904205ff7d6aa8cb"}, + {file = "coverage-5.0.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:ea9525e0fef2de9208250d6c5aeeee0138921057cd67fcef90fbed49c4d62d37"}, + {file = "coverage-5.0.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:c62a2143e1313944bf4a5ab34fd3b4be15367a02e9478b0ce800cb510e3bbb9d"}, + {file = "coverage-5.0.3-cp38-cp38m-win32.whl", hash = "sha256:b0840b45187699affd4c6588286d429cd79a99d509fe3de0f209594669bb0954"}, + {file = "coverage-5.0.3-cp38-cp38m-win_amd64.whl", hash = "sha256:76e2057e8ffba5472fd28a3a010431fd9e928885ff480cb278877c6e9943cc2e"}, + {file = "coverage-5.0.3-cp39-cp39m-win32.whl", hash = "sha256:b63dd43f455ba878e5e9f80ba4f748c0a2156dde6e0e6e690310e24d6e8caf40"}, + {file = "coverage-5.0.3-cp39-cp39m-win_amd64.whl", hash = "sha256:da93027835164b8223e8e5af2cf902a4c80ed93cb0909417234f4a9df3bcd9af"}, + {file = "coverage-5.0.3.tar.gz", hash = "sha256:77afca04240c40450c331fa796b3eab6f1e15c5ecf8bf2b8bee9706cd5452fef"}, +] cycler = [ {file = "cycler-0.10.0-py2.py3-none-any.whl", hash = "sha256:1d8a5ae1ff6c5cf9b93e8811e581232ad8920aeec647c37316ceac982b08cb2d"}, {file = "cycler-0.10.0.tar.gz", hash = "sha256:cd7b2d1018258d7247a71425e9f26463dfb444d411c39569972f4ce586b0c9d8"}, diff --git a/pyproject.toml b/pyproject.toml index 2e62264..6e94fa7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,7 @@ pyls-black = "^0.4.4" sphinx = "^2.4.4" sphinx_rtd_theme = "^0.4.3" sphinx-click = "^2.3.1" +coverage = "^5.0.3" [tool.poetry.plugins."console_scripts"] "musicbrainzapi" = "musicbrainzapi.cli.cli:cli"