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

Deprecation warning in plugins.py #2826

Closed
akyag opened this issue Feb 28, 2018 · 13 comments
Closed

Deprecation warning in plugins.py #2826

akyag opened this issue Feb 28, 2018 · 13 comments
Labels
bug bugs that are confirmed and actionable

Comments

@akyag
Copy link

akyag commented Feb 28, 2018

Problem

Installed beets from fedora repo and getting the following error every time I run any command

Running this command in verbose (-vv) mode:

[akya@quady scripts] $ beet -vv
user configuration: /home/akya/.config/beets/config.yaml
data directory: /home/akya/.config/beets
plugin paths: /home/akya/.config/beets/beetsplug
/usr/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py:46: DeprecationWarning: OpenSSL.rand is deprecated - you should use os.urandom instead
  import OpenSSL.SSL
Sending event: pluginload
/usr/lib/python3.6/site-packages/beets/plugins.py:114: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
  argspec = inspect.getargspec(func)
lyrics: Disabling google source: no API key configured.
library database: /home/akya/data/musiclibrary.db
library directory: /media/Media/Songs/English
Sending event: library_opened
Usage: 
  beet COMMAND [ARGS...]
  beet help COMMAND

Options:
  --format-item=FORMAT_ITEM
                        print with custom format
  --format-album=FORMAT_ALBUM
                        print with custom format
  -l LIBRARY, --library=LIBRARY
                        library database file to use
  -d DIRECTORY, --directory=DIRECTORY
                        destination music directory
  -v, --verbose         log more details (use twice for even more)
  -c CONFIG, --config=CONFIG
                        path to configuration file
  -h, --help            show this help message and exit

Commands:
  bad               check for corrupt or missing files
  clearart          remove images from file metadata
  config            show or edit the user configuration
  convert           convert to external location
  duplicates (dup)  List duplicate tracks or albums.
  embedart          embed image files into file metadata
  extractart        extract an image from file metadata
  fetchart          download album art
  fields            show fields available for queries and format strings
  help (?)          give detailed help on a specific sub-command
  import (imp, im)  import new music
  info              show file metadata
  lastgenre         fetch genres
  list (ls)         query the library
  lyrics            fetch song lyrics
  missing (miss)    List missing tracks.
  modify (mod)      change metadata fields
  move (mv)         move or copy items
  play              send music to a player as a playlist
  remove (rm)       remove matching items from the library
  splupdate         update the smart playlists. Playlist names may be passed
                    as arguments.
  stats             show statistics about the library or a query
  update (upd, up)  update the library
  version           output version information
  web               start a Web interface
  write             write tag information to files
Sending event: cli_exit

Led to this problem:

[akya@quady scripts] $ beet --version
/usr/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py:46: DeprecationWarning: OpenSSL.rand is deprecated - you should use os.urandom instead
  import OpenSSL.SSL
/usr/lib/python3.6/site-packages/beets/plugins.py:114: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
  argspec = inspect.getargspec(func)
beets version 1.4.6
Python version 3.6.4
plugins: badfiles, beatport, convert, duplicates, embedart, fetchart, info, lastgenre, lyrics, missing, mpdupdate, play, smartplaylist, web

Here's a link to the music files that trigger the bug (if relevant):

Setup

  • OS: Fedora 27
  • Python version: 3.6.4
  • beets version: 1.4.6
  • Turning off plugins made problem go away (yes/no): yes, problem is in plugins.py

My configuration (output of beet config) is:

directory: /media/Media/Songs/English
#directory: /media/Media/Songs/Hindi
library: ~/data/musiclibrary.db
#library: ~/data/musiclibrary2.db
import:
    copy: no
    write: yes
    log: /home/akya/.config/beets/import.log

pluginpath: 
    - /home/akya/.config/beets/beetsplug/

plugins: fetchart embedart lastgenre lyrics web missing beatport duplicates convert info play smartplaylist mpdupdate badfiles

play:
    command: mpv $args --playlist

mpd:
    host: 192.168.1.100
    port: 6600

fetchart:
    cautious: true
    cover_names: front back
    minwidth: 300
    sources: itunes *

smartplaylist:
    relative_to: 
    playlist_dir: ~/.mpd/playlists
    playlists:
        - name: fav.m3u
          query: 'comments:Fav'
        - name: new.m3u
          query: 'comments:New'
        - name: epic.m3u
          query: 'comments:Epic'
        - name: lush.m3u
          query: 'comments:Lush'
        - name: naruto.m3u
          query: 'comments:Naruto'
        - name: latest.m3u
          query: 'added:2017-11-27'
convert:
    format: mp3
    dest: /home/akya/1Dump/sync
    max_bitrate: 320
    never_convert_lossy_files: yes


paths:
    default: $albumartist/$album%aunique{}/$track $title
#    default: $album%aunique{}/$track $title
    singleton: Non-Album/$artist - $title
    comp: Compilations/$album%aunique{}/$track $title
@sampsyo sampsyo added the needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." label Feb 28, 2018
@sampsyo
Copy link
Member

sampsyo commented Feb 28, 2018

Hi! That’s interesting—thanks for reporting. Do you know why you might be seeing this while other users (like myself) on 3.6 don’t? Is this a brand-new deprecation in a point release, or is this somehow a Debian-related thing?

@akyag
Copy link
Author

akyag commented Feb 28, 2018

Earlier I was using beets from pip.. It was 1.4.5 I think, but then I saw that beets was available in dnf, I removed the one from pip and installed from DNF.. Since then I am seeing this.. If I remove the plugins in the config, I don't see any error.

@sampsyo
Copy link
Member

sampsyo commented Feb 28, 2018

Thanks. Looks like we need an updated call akin to this change: https://github.com/praw-dev/praw/pull/551/files#diff-2a573d21bf9c7db67d16b42ba4e8193eR37

@sampsyo sampsyo added bug bugs that are confirmed and actionable and removed needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." labels Feb 28, 2018
@MorgothSauron
Copy link

I can't remember exactly when it started, but I got this DeprecationWarning on Fedora 27 for quite a while. The error remains after upgrade to Fedora 28.

  • beet version (installed from Fedora repository:
$ beet --version
/usr/lib/python3.6/site-packages/beets/plugins.py:114: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
  argspec = inspect.getargspec(func)
beets version 1.4.6
Python version 3.6.5
plugins: embedart, fetchart, info, lyrics
$ 
  • Fedora release
$ lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: Fedora
Description:    Fedora release 28 (Twenty Eight)
Release:        28
Codename:       TwentyEight
$ 
  • python versions
$ python --version
Python 2.7.15
$ python3 --version
Python 3.6.5

@zhelezov
Copy link
Contributor

zhelezov commented Dec 8, 2018

Same here: Fedora 29, beets 1.4.7
On running beets I get these warnings:

/usr/lib/python3.7/site-packages/socks.py:58: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3
.8 it will stop working                   
  from collections import Callable    
/usr/lib/python3.7/site-packages/beets/plugins.py:130: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
  argspec = inspect.getargspec(func)              
/usr/lib64/python3.7/site-packages/yaml/constructor.py:126: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprec
ated, and in 3.8 it will stop working     
  if not isinstance(key, collections.Hashable):

Otherwise functions normally. Same behavior from repository package and pip install :-(

@sampsyo
Copy link
Member

sampsyo commented Dec 9, 2018

Strange that this seems to occur on some distros but not others.

The last one, at least, should be fairly straightforward to fix if anyone's interested in lending a hand!

@zhelezov
Copy link
Contributor

zhelezov commented Dec 9, 2018

It must be that Fedora's Python build has some debug flags on that help catch stuff like this. Anyways a simple change of inspect.getargspec() with inspect.getfullargspec() is all is needed for PY3 to stop complaining. It would break beets on PY2 though.

Edit: or, sth like this:

diff --git a/beets/plugins.py b/beets/plugins.py
index 6dec7ef2..c26b1034 100644
--- a/beets/plugins.py
+++ b/beets/plugins.py
@@ -20,6 +20,7 @@ from __future__ import division, absolute_import, print_function
 import inspect
 import traceback
 import re
+import sys
 from collections import defaultdict
 from functools import wraps
 
@@ -127,7 +128,10 @@ class BeetsPlugin(object):
         value after the function returns). Also determines which params may not
         be sent for backwards-compatibility.
         """
-        argspec = inspect.getargspec(func)
+        if sys.version_info[0] < 3:
+            argspec = inspect.getargspec(func)
+        else:
+            argspec = inspect.getfullargspec(func)
 
         @wraps(func)
         def wrapper(*args, **kwargs):

Still more stuff to clean afterwards on the way to PY3 only though...

@sampsyo
Copy link
Member

sampsyo commented Dec 9, 2018

We also have six as a dependency, so if six.PY2: could be a little simpler.

@zhelezov
Copy link
Contributor

zhelezov commented Dec 9, 2018

Well, no need for superfluous imports then:

diff --git a/beets/plugins.py b/beets/plugins.py
index 6dec7ef2..69784d26 100644
--- a/beets/plugins.py
+++ b/beets/plugins.py
@@ -127,7 +127,10 @@ class BeetsPlugin(object):
         value after the function returns). Also determines which params may not
         be sent for backwards-compatibility.
         """
-        argspec = inspect.getargspec(func)
+        if six.PY2:
+            argspec = inspect.getargspec(func)
+        else:
+            argspec = inspect.getfullargspec(func)
 
         @wraps(func)
         def wrapper(*args, **kwargs):

@sampsyo
Copy link
Member

sampsyo commented Dec 9, 2018

Awesome. Would you mind opening a pull request with that patch?

@zhelezov zhelezov mentioned this issue Dec 10, 2018
ssssam added a commit to ssssam/beets that referenced this issue Mar 4, 2019
Fixes the following warning from certain versions of Python 3.7:

    /home/sam/.local/lib/python3.7/site-packages/beets/plugins.py:130: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
      argspec = inspect.getargspec(func)

Patch from beetbox#2826
@ssssam
Copy link
Contributor

ssssam commented Mar 4, 2019

I've been seeing several unrelated deprecation warnings from Beets since upgrading my laptop, and I tracked it down to the musicbrainzngs library. Version 0.5 of that library will turn on deprecation warnings process-wide in any program which imports it.

The issue was fixed in musicbrainzngs 0.6, but Fedora only packages version 0.5 so anyone using that distro will be seeing some warnings. I've opened a bug in Fedora here: https://bugzilla.redhat.com/show_bug.cgi?id=1685216

You can work around this by installing a local copy of musicbrainzngs using pip3 install --user --upgrade

@sampsyo
Copy link
Member

sampsyo commented Mar 4, 2019

That's really helpful to know; thanks, @ssssam!

zhelezov added a commit to zhelezov/beets that referenced this issue Mar 5, 2019
@zhelezov
Copy link
Contributor

zhelezov commented Mar 5, 2019

Thanks for the research you've done @ssssam! I can confirm that I got rid of the screenful of warnings I got with the packaged version in Fedora after installing a local copy of musicbrainzngs. In any case the deprecated usage is still there even if nagging stopped so I updated my PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs that are confirmed and actionable
Projects
None yet
Development

No branches or pull requests

5 participants