Skip to content

MNT Run dos2unix #21053

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

Merged
merged 2 commits into from
Feb 10, 2022
Merged

MNT Run dos2unix #21053

merged 2 commits into from
Feb 10, 2022

Conversation

DimitriPapadopoulos
Copy link
Contributor

@DimitriPapadopoulos DimitriPapadopoulos commented Sep 15, 2021

What does this implement/fix? Explain your changes.

Run dos2unix on 4 files with CR LF Windows line endings instead of LF Unix line endings.

My initial motivation was that some diff tools show the additional CR as an annoying bold and red "^M"!

Any other comments?

Initially part of #21051.

Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

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

Hi @DimitriPapadopoulos,

Thanks for unifying line endings, this sounds reasonable.

However contribution changes can't be integrated if there are linting errors, which is de facto to the case here.

The pre-commit setup should solve some of the problem. You can trigger it by calling black and by then committing changes.

@DimitriPapadopoulos
Copy link
Contributor Author

i'll run black into a different commit, but same PR. Should fix the problem.

@DimitriPapadopoulos DimitriPapadopoulos force-pushed the dos2unix branch 2 times, most recently from 4cef309 to 8b979c1 Compare September 30, 2021 13:36
@DimitriPapadopoulos DimitriPapadopoulos force-pushed the dos2unix branch 4 times, most recently from 053b03e to 9c9090f Compare October 5, 2021 21:56
Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

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

This LGTM after removing some dead code. Thanks @DimitriPapadopoulos.

Comment on lines 1213 to 1217
# ~ 'decorator to trim function calls to match the arity of the target'
# ~ def _trim_arity(func, maxargs=3):
# ~ if func in singleArgBuiltins:
# ~ return lambda s,l,t: func(t)
# ~ limit = 0
# ~ foundArity = False
# ~ def wrapper(*args):
# ~ nonlocal limit,foundArity
# ~ while 1:
# ~ try:
# ~ ret = func(*args[limit:])
# ~ foundArity = True
# ~ return ret
# ~ except TypeError:
# ~ if limit == maxargs or foundArity:
# ~ raise
# ~ limit += 1
# ~ continue
# ~ return wrapper
Copy link
Member

Choose a reason for hiding this comment

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

This can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about this one:

The function that is commented out is for Python 3:

# Only works on Python 3.x - nonlocal is toxic to Python 2 installs
#~ 'decorator to trim function calls to match the arity of the target'
#~ def _trim_arity(func, maxargs=3):

The current function is for Python 2-3:

# this version is Python 2.x-3.x cross-compatible
'decorator to trim function calls to match the arity of the target'
def _trim_arity(func, maxargs=2):

Shouldn't we discard the current Python 2-3 code and enable the commented out Python 3 code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel this should be handled in a different PR.

Copy link
Member

Choose a reason for hiding this comment

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

That's a good question. Even though Python 2 is not supported anymore, a conservative choice would be to keep the current one if it works for Python 3. But the commented one used for Python 3 is way smaller and using it this would ease maintenance.

In any case, I am not sure if tutorial are referenced nor used anymore.

Cc: @glemaitre for a more authoritative point of view.

@DimitriPapadopoulos DimitriPapadopoulos force-pushed the dos2unix branch 4 times, most recently from ead6ffa to 502ca37 Compare October 6, 2021 18:27
@jjerphan
Copy link
Member

jjerphan commented Oct 7, 2021

Please @DimitriPapadopoulos, do not force-push if your PRs got one or more review as reviews have to be done again entirely. Also, from a git log point of view, this won't have an impact because commits are squashed.

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @DimitriPapadopoulos !

Since doc/tutorial/machine_learning_map/pyparsing.py and doc/tutorial/machine_learning_map/parse_path.py look vendored, I suggest not to change them.

I think we can keep the change in doc/tutorial/machine_learning_map/svg2imagemap.py and sklearn/svm/_newrand.pyx.

DimitriPapadopoulos and others added 2 commits February 10, 2022 14:45
A handful files had CRLF Windows line endings. Change to LF Unix line
endings for consistency, and because some diff tools show the additional
CR as an annoying bold and red "^M"!
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
@DimitriPapadopoulos
Copy link
Contributor Author

Ah, I hadn't noticed these two files are vendored files. I've removed these files from the commits.

@thomasjpfan thomasjpfan changed the title dos2unix MNT Run dos2unix Feb 10, 2022
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM

@thomasjpfan thomasjpfan merged commit 84bc634 into scikit-learn:main Feb 10, 2022
@DimitriPapadopoulos DimitriPapadopoulos deleted the dos2unix branch February 11, 2022 18:18
thomasjpfan pushed a commit to thomasjpfan/scikit-learn that referenced this pull request Mar 1, 2022
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants