-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
build: refactor configure.py #47323
build: refactor configure.py #47323
Conversation
Note that the tests are failing because the |
762c432
to
14b08f7
Compare
FWIW some previous discussion in #42186. |
I'm not sure about that, we'll have to switch either way though we could make our own class/function implementing version parsing but it's too much work for the simple use cases here, so I'd say we should make the move to the |
14b08f7
to
4863d58
Compare
f2d5605
to
e6931de
Compare
configure.py
Outdated
def icu_download(path): | ||
def icu_download(): |
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.
I'm not sure about this change, the path
parameter of the icu_download()
function was never used (not inside the function I mean), not even from the day it was added.
But an argument to the path
parameter is being passed here:
Line 1819 in 069365c
localzip = icu_download(icu_full_path) |
even though it's not used inside the icu_download()
function, is this a mistake or was it supposed to be used?
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.
👍 Let's revert this change and put a # noqa
here to placate the linter.
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.
Why should we revert this? Do you want me to make this change in a separate PR?
e6931de
to
9a0a399
Compare
@nodejs/python |
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.
This is a legacy codebase that a lot of folks depend on so we want to keep any possible breakage to a minimum. Here are some ideas...
Also, I would like to land #47519 before we land this so we have some stronger guardrails in place.
configure.py
Outdated
def icu_download(path): | ||
def icu_download(): |
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.
👍 Let's revert this change and put a # noqa
here to placate the linter.
ed5706f
to
89e91ed
Compare
This comment was marked as outdated.
This comment was marked as outdated.
edf05e6
to
ff0ff9b
Compare
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.
more ideas
I know we are only changing a single file but it is a vital file and I do not know if it has enough tests... Perhaps we should introduce these changes in multiple PRs. Your thoughts on test coverage?
dec8698
to
f3c8e7f
Compare
- Explicitly specify the encoding when opening files. - Use f-strings to format strings. - Use `isinstance()` for type checks instead of `type()`. - Use the `with` keyword for resource-allocating operations. - Avoid using multiple statements in a single line. - Remove unnecessary `else` clauses after `return`. - Iterate with the `items()` method of dictionaries when both the key and value are used. - Remove unnecessary parentheses. - Rename unused unpacked variables to `_`, `_1`, etc etc. - Rename the `list` variable to avoid conflict with the global `list()` function. - Remove unused `path` parameter of the `icu_download()` function. - Use the `pathlib` library for paths instead of `os.path`.
f3c8e7f
to
68ef467
Compare
I'm fine with that, should I introduce each of these changes in separate PRs to reduce review time?
Writing new tests for such build files sounds like a good idea, but I have no experience writing tests for such files 😅. |
@@ -53,8 +56,7 @@ | |||
valid_mips_fpu = ('fp32', 'fp64', 'fpxx') | |||
valid_mips_float_abi = ('soft', 'hard') | |||
valid_intl_modes = ('none', 'small-icu', 'full-icu', 'system-icu') | |||
with open ('tools/icu/icu_versions.json') as f: | |||
icu_versions = json.load(f) | |||
icu_versions = json.loads((tools_path / 'icu' / 'icu_versions.json').read_text()) |
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.
.read_text(encoding='utf-8')
is also possible.
I think we should get this PR will all changes ready and with all tests passing. Then we should have a second PR that is a strict subset of these changes. We land the second PR first and then after a release and user feedback, we rebase this PR and push the remaining into the next Node release. All the pathlib changes should land separately from all other changes. Thoughts? Or am I just being too paranoid? |
What changes here counts as a strict subset?
That's a good idea. |
The pathlib changes vs. all non-pathlib changes. |
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: nodejs#47323 (comment) nodejs#47323 (comment)
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: nodejs#47323 (comment) nodejs#47323 (comment)
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: nodejs#47323 (comment) nodejs#47323 (comment)
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: nodejs#47323 (comment) nodejs#47323 (comment)
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: nodejs#47323 (comment) nodejs#47323 (comment)
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: nodejs#47323 (comment) nodejs#47323 (comment)
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: nodejs#47323 (comment) nodejs#47323 (comment)
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: nodejs#47323 (comment) nodejs#47323 (comment)
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: nodejs#47323 (comment) nodejs#47323 (comment)
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: #47323 (comment) #47323 (comment) PR-URL: #47581 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Christian Clauss <[email protected]>
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: #47323 (comment) #47323 (comment) PR-URL: #47581 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Christian Clauss <[email protected]>
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: #47323 (comment) #47323 (comment) PR-URL: #47581 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Christian Clauss <[email protected]>
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: #47323 (comment) #47323 (comment) PR-URL: #47581 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Christian Clauss <[email protected]>
Use Python's `pathlib` library for paths and related operations instead of `os.path`. Refs: nodejs#47323 (comment) nodejs#47323 (comment) PR-URL: nodejs#47581 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Christian Clauss <[email protected]>
broke ICU downloading on windows (the 'path' argument is a URL or a file path) - see #55214 |
isinstance()
for type checks instead oftype()
.with
keyword for resource-allocating operations.else
clauses afterreturn
.items()
method of dictionaries when both the key and value are used._
,_1
, etc etc.list
variable to avoid conflict with the globallist()
function.path
parameter of theicu_download()
function.pathlib
library for paths instead ofos.path
.