fix: pkg_resources deprecation warning on runtime#307
Conversation
| import pkg_resources | ||
| from pkg_resources import DistributionNotFound | ||
| version = pkg_resources.require("razorpay")[0].version | ||
| except (PackageNotFoundError, DistributionNotFound, NameError): # pragma: no cover |
There was a problem hiding this comment.
Catching multiple exceptions ensures robustness, but consider logging a warning if version retrieval fails, to aid client debugging.
There was a problem hiding this comment.
Catching NameError is thoughtful for edge-case compatibility, but it may also mask unrelated issues. Consider logging or at least adding a comment for future maintainers.
| # DistributionNotFound: pkg_resources couldn't find the package | ||
| # NameError: in case the exception classes aren't defined due to import issues | ||
| pass | ||
| return version |
There was a problem hiding this comment.
Returning an empty string on exception is safe, but would it be more useful to return None or log a warning for SDK users who may rely on version info?
There was a problem hiding this comment.
@razorpay-sanjib Returning None would break the string formatting in User-Agent header. but we can add warning like this
except:
warnings.warn(
"Could not detect razorpay package version. Using fallback version. "
"This may indicate an installation issue.",
UserWarning,
stacklevel=4
)
return version
…orpay/razorpay-python into fix/pkg_resource-deprecation
Reference: razorpay/razorpay-python#307 TODO: Rebase
pkg_resources has been removed from Setuptools v82.0.0 Razorpay 1.2.0 depends on pkg_resources. razorpay/razorpay-python#307 Ref: https://setuptools.pypa.io/en/stable/history.html#deprecations-and-removals
Reference: razorpay/razorpay-python#307 TODO: Rebase
pkg_resources has been removed from Setuptools v82.0.0 Razorpay 1.2.0 depends on pkg_resources. razorpay/razorpay-python#307 Packages from dev-requirements (e.g. moto) ask for setuptools>=x, that fetches the latest setuptools, ignoring the previous constraints. So, pin setuptools in dev-requirements.txt Ref: https://setuptools.pypa.io/en/stable/history.html#deprecations-and-removals
pkg_resources has been removed from Setuptools v82.0.0 Razorpay 1.2.0 depends on pkg_resources. razorpay/razorpay-python#307 Packages from dev-requirements (e.g. moto) ask for setuptools>=x, that fetches the latest setuptools, ignoring the previous constraints. So, pin setuptools in dev-requirements.txt Ref: https://setuptools.pypa.io/en/stable/history.html#deprecations-and-removals (cherry picked from commit 98bc36b)
|
means razorpay-python still use pkg_resources ? in client.py |
pkg_resources has been removed from Setuptools v82.0.0 Razorpay 1.2.0 depends on pkg_resources. razorpay/razorpay-python#307 Packages from dev-requirements (e.g. moto) ask for setuptools>=x, that fetches the latest setuptools, ignoring the previous constraints. So, pin setuptools in dev-requirements.txt Ref: https://setuptools.pypa.io/en/stable/history.html#deprecations-and-removals
Fix deprecation warning on runtime