Replace deprecated pkg_resources with importlib.metadata#1555
Open
ianhandy wants to merge 1636 commits intonvbn:masterfrom
Open
Replace deprecated pkg_resources with importlib.metadata#1555ianhandy wants to merge 1636 commits intonvbn:masterfrom
ianhandy wants to merge 1636 commits intonvbn:masterfrom
Conversation
Sample command output is:
Error: This command updates brew itself, and does not take formula names.
Use 'brew upgrade thefuck' instead.
This will never match the previous `"Use 'brew upgrade <formula>'" in command.output` test.
…into matthewfallshaw-patch-1
Unfortunately, I didn't catch these issues while reviewing nvbn#702. After looking more closely at `php` options, `-S` requires additional arguments (<address>:<port>) and `-s` may produce output if used that way. So, matching ` -s ` seems to be better. Also, `@for_app('php')` already asserts the presence of `php ` in the command script. Matching `php -s` prevents the rule from fixing commands like `php -t public -s 0.0.0.0:8080`.
This helps you run `apt list --upgradable` after `apt update`, as it suggests.
See nvbn#744 for context. I'm personally okay with dropping Python 3.3 support, but I'd like to at least get the tests working while we decide on that.
* Add missing comma in a test
* Add pikaur AUR manager to Arch Linux's commands * Update README.md * Update test_pacman_not_found.py * Update pacman_not_found.py * Update README.md
* macos shutdown sudo fix * Update tests/rules/test_sudo.py * Update thefuck/rules/sudo.py * Update tests/rules/test_sudo.py * Update thefuck/rules/sudo.py
* added updatedb(mlocate) to sudo rules * Add test
* fix: brew_update_formula change output string * fix: regex removed, test: backtick added * Update tests/rules/test_brew_update_formula.py * Update thefuck/rules/brew_update_formula.py
* fix: Update output for brew_install test: fixed * chore: fixing flake8 styles * feat: show more suggestions * test: new functions added and multi suggestions * refactor: rename to _get_suggestions
* Add git clone missing rule * Clean up tests and improve matching * Make rules behave correctly? * Improve tests and redo matcher * Remove unnecessary tests * Improvements as per code review * Remove dead tests * Improve match function for git clone missing * Improve tests * Fix more tests * Fix failing test * Add Macos's /bin/sh command output to match * Add output for lines uncovered by tests
* Add terraform 'no command' rule * Feedback from PR
The imp module is deprecated and will be removed in Python 12.
* feat: Added nicer support for Windows CMD & Powershell * Fix typo * Fix CMD console color after thefuck Ctrl-C * Update setup.py * Update setup.py * Addressed PR comments * fix spacing and newline issues ---------
pkg_resources (from setuptools) is deprecated and causes issues on Python 3.12+ where it may not be available. Replace all usage with importlib.metadata (stdlib since Python 3.8), with a fallback to the importlib_metadata backport for older Python versions. Fixes nvbn#1552
1c4c4db to
92c8c67
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pkg_resourcesusage withimportlib.metadata(stdlib since Python 3.8)importlib_metadatabackport for older Python versionssetup.pypip version check andutils.pyversion lookupFixes #1552
Changes
setup.py: Replacedpkg_resources.get_distribution("pip").versionwithimportlib.metadata.version("pip")andpkg_resources.DistributionNotFoundwithPackageNotFoundError.thefuck/utils.py: Simplifiedget_installation_version()— removedpkg_resourcesfallback, usingimportlib.metadatawithimportlib_metadatabackport fallback instead.Test plan
🤖 Generated with Claude Code