Skip to content

remove unused pkg_resources import#3512

Merged
bthirion merged 1 commit intonilearn:mainfrom
drammock:remove-unused-import
Feb 15, 2023
Merged

remove unused pkg_resources import#3512
bthirion merged 1 commit intonilearn:mainfrom
drammock:remove-unused-import

Conversation

@drammock
Copy link
Copy Markdown
Contributor

@drammock drammock commented Feb 14, 2023

The MNE-Python CIs are hitting a new DeprecationWarning today when we import nilearn. It appears to arise from the (unused) importing of pkg_resources in your __init__.py. Locally when I run pytest nilearn after this change, all tests pass, and pip install -e . into a clean environment also works, so I'm pretty sure that import was just cruft.

Here's the warning we've been hitting, FYI:

Details
mne/viz/tests/test_3d_mpl.py:34: in <module>
    @requires_version('nilearn', '0.4')
mne/utils/_testing.py:94: in requires_version
    return pytest.mark.skipif(not check_version(library, min_version),
mne/utils/check.py:106: in check_version
    library = import_module(library)
/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1050: in _gcd_import
    ???
<frozen importlib._bootstrap>:1027: in _find_and_load
    ???
<frozen importlib._bootstrap>:1006: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:688: in _load_unlocked
    ???
<frozen importlib._bootstrap_external>:883: in exec_module
    ???
<frozen importlib._bootstrap>:241: in _call_with_frames_removed
    ???
/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/nilearn/__init__.py:39: in <module>
    import pkg_resources
/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pkg_resources/__init__.py:3257: in <module>
    def _initialize_master_working_set():
/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pkg_resources/__init__.py:3231: in _call_aside
    f(*args, **kwargs)
/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pkg_resources/__init__.py:3282: in _initialize_master_working_set
    tuple(dist.activate(replace=False) for dist in working_set)
/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pkg_resources/__init__.py:3282: in <genexpr>
    tuple(dist.activate(replace=False) for dist in working_set)
/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pkg_resources/__init__.py:2803: in activate
    declare_namespace(pkg)
/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/pkg_resources/__init__.py:2297: in declare_namespace
    warnings.warn(msg, DeprecationWarning, stacklevel=2)
E   DeprecationWarning: Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages

Changes proposed in this pull request:

  • remove unused import of pkg_resources in __init__.py

EDIT: pasted wrong traceback the first time. fixed now.

@github-actions
Copy link
Copy Markdown
Contributor

👋 @drammock Thanks for creating a PR!

Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft.

Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.

  • PR has an interpretable title.
  • PR links to Github issue with mention "Closes #XXXX"
  • Code is PEP8-compliant.
  • Changelog or what's new entry in "doc/changes/latest.rst"
  • (Bug fixes) There is at least one test that would fail under the original bug conditions.
  • (New features) There is at least one unit test per new function / class.
  • (New features) The new feature is demoed in at least one relevant example.

We will review it as quick as possible, feel free to ping us with questions if needed.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 14, 2023

Codecov Report

Merging #3512 (4f14146) into main (2a503a4) will decrease coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #3512      +/-   ##
==========================================
- Coverage   91.00%   91.00%   -0.01%     
==========================================
  Files         133      133              
  Lines       15358    15357       -1     
  Branches     3034     3034              
==========================================
- Hits        13977    13976       -1     
  Misses        817      817              
  Partials      564      564              
Impacted Files Coverage Δ
nilearn/__init__.py 90.00% <ø> (-0.48%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Copy Markdown
Member

@ymzayek ymzayek left a comment

Choose a reason for hiding this comment

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

LGTM thanks @drammock !

Copy link
Copy Markdown
Member

@NicolasGensollen NicolasGensollen left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @drammock !

@bthirion bthirion merged commit 68f4b48 into nilearn:main Feb 15, 2023
@bthirion
Copy link
Copy Markdown
Member

Thx !

@drammock drammock deleted the remove-unused-import branch February 15, 2023 15:47
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.

4 participants