-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Avoid using private _config_vars
#4228
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
Conversation
@@ -33,7 +33,7 @@ def environment(monkeypatch): | |||
monkeypatch.setattr(os.path, 'join', os.path.join) | |||
monkeypatch.setattr(os.path, 'isabs', os.path.isabs) | |||
monkeypatch.setattr(os.path, 'splitdrive', os.path.splitdrive) | |||
monkeypatch.setattr(sysconfig, '_config_vars', copy(sysconfig._config_vars)) | |||
monkeypatch.setattr(sysconfig, 'get_config_vars', sysconfig.get_config_vars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in setuptools/_distutils/tests/test_util.py
are overwritten every time setuptools
syncs up with pypa/distutils
, so probably they have to be proposed in the pypa/distutils
repository first and later merged here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I can go make the changes upstream to the right place.
Hi @Avasam, thank you for the contribution and all the effort you are putting toward improving the typing in setuptools.
I don't understand this comment, could you please expland a little bit... Isn't Other than that,
Footnotes
|
Only if it was
Possibly? But setuptools is also in control of that now that distutils isn't part of the stdlib. (and I doubt a security update to Python 3.8 - 3.11 would change this behaviour)
Whilst I'm challenging the use of a variable that is both private and not exposed in stubs, if you truly believe this is what setuptools should be doing, then I can expose |
Thank you very much @Avasam for having a deeper look on this.
My personal opinion is that The reality is that the patch is entangled to depend on that particular private variable... The moment the implementation changes everything falls apart. By importing the private attribute, at least we have a small "sanity check" giving hints about the global change in the state being necessary for the patching to have the desirable effect. Unless Jason have requested this change, I think we can just be happy with our lives and add an |
A type-ignore with an explicit type declaration (or cast if it's really needed) with a documented resolution is fine by me in this case. |
+ try to resolve doc issue
Closed by 55eeabd |
* Fix all mypy issues * Ran black * Exclude tox from mypy check * Fix all mypy issues again * Address PR comments * Fix accidental line ending changes * Update .gitignore * No unused type: ignore * TypeError: 'ABCMeta' object is not subscriptable * Fix RuffError * Fix post-merge mypy issues * RUff format * Ignore more generated files * Disable more mypy errors * Globally ignore attr-defined for now * Update more comments * Address PR comments and fix new exposed typing issues * Comments updates and don't touch vendored * Accidentally removed noqa * Update setuptools/tests/integration/test_pip_install_sdist.py Co-authored-by: Anderson Bravalheri <[email protected]> * Post merge comments Update setuptools/tests/integration/test_pip_install_sdist.py Co-authored-by: Anderson Bravalheri <[email protected]> * Document that usage of _config_vars is very purposeful Closes #4228 + try to resolve doc issue * sort nitpick_ignore * Make only comment on newline like others * Forgot to re-ignore --------- Co-authored-by: Anderson Bravalheri <[email protected]>
Summary of changes
This PR attempts to avoid using a private global variables, to instead use the available public API. This resolves a
noqa
and upcommingtype: ignore
in https://github.com/pypa/setuptools/pull/3979/files#diff-820ceee125a584dd996725a342b2aaec47c5e96399faf426348dfeebe242ea4bR31All 3 implementations of
get_config_vars
(insysconfig
,distutils.sysconfig
, andsetuptools._distutils.sysconfig
) return the global dictionary directly (not a copy), so usage inbuild_ext
should be equivalent.get_config_vars
also already ensures_config_vars
is initializedI'm not sure about the test change however.
Pull Request Checklist
newsfragments/
. (I don't think this counts as user-facing changes?)(See documentation for details)