-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG] MNT Ignore E731: Use a def instead of lambda #8131
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
Closed
Closed
Conversation
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
We don't follow this and lambdas are quite common in the scientific programming world. Our contributors will more often use lambdas compared to diff for one-liners...
I'd rather a def. I think people write lambdas thinking it's doing
something different. They're wrong. Defs provide a name in the traceback.
…On 29 December 2016 at 08:05, (Venkat) Raghav (Rajagopalan) < ***@***.***> wrote:
Our flake8 checker in travis raises error for lambdas for one-liners. I
don't think we follow that. Most contributors might prefer lambdas
actually...
Ref lambda check_df = lambda x: isinstance(x, InputFeatureType)
<https://github.com/scikit-learn/scikit-learn/pull/5697/files#diff-d51a9726ff1d2791c05babac47e936d5R984>
@GaelVaroquaux <https://github.com/GaelVaroquaux> @jnothman
<https://github.com/jnothman> Is this fine with you?
------------------------------
You can view, comment on, or merge this pull request online at:
#8131
Commit Summary
- MNT Ignore E731: Use a def instead of lambda
File Changes
- *M* build_tools/travis/flake8_diff.sh
<https://github.com/scikit-learn/scikit-learn/pull/8131/files#diff-0>
(4)
Patch Links:
- https://github.com/scikit-learn/scikit-learn/pull/8131.patch
- https://github.com/scikit-learn/scikit-learn/pull/8131.diff
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8131>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AAEz688hs4q9nckh3Iq7bwejPkRRL7Aaks5rMs78gaJpZM4LXMBs>
.
|
In tests I might make an exception.
…On 29 December 2016 at 13:43, Joel Nothman ***@***.***> wrote:
I'd rather a def. I think people write lambdas thinking it's doing
something different. They're wrong. Defs provide a name in the traceback.
On 29 December 2016 at 08:05, (Venkat) Raghav (Rajagopalan) <
***@***.***> wrote:
> Our flake8 checker in travis raises error for lambdas for one-liners. I
> don't think we follow that. Most contributors might prefer lambdas
> actually...
>
> Ref lambda check_df = lambda x: isinstance(x, InputFeatureType)
> <https://github.com/scikit-learn/scikit-learn/pull/5697/files#diff-d51a9726ff1d2791c05babac47e936d5R984>
>
> @GaelVaroquaux <https://github.com/GaelVaroquaux> @jnothman
> <https://github.com/jnothman> Is this fine with you?
> ------------------------------
> You can view, comment on, or merge this pull request online at:
>
> #8131
> Commit Summary
>
> - MNT Ignore E731: Use a def instead of lambda
>
> File Changes
>
> - *M* build_tools/travis/flake8_diff.sh
> <https://github.com/scikit-learn/scikit-learn/pull/8131/files#diff-0>
> (4)
>
> Patch Links:
>
> - https://github.com/scikit-learn/scikit-learn/pull/8131.patch
> - https://github.com/scikit-learn/scikit-learn/pull/8131.diff
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#8131>, or mute the
> thread
> <https://github.com/notifications/unsubscribe-auth/AAEz688hs4q9nckh3Iq7bwejPkRRL7Aaks5rMs78gaJpZM4LXMBs>
> .
>
|
Rather, as local closures, usually in tests, I might make an exception.
…On 29 December 2016 at 13:47, Joel Nothman ***@***.***> wrote:
In tests I might make an exception.
On 29 December 2016 at 13:43, Joel Nothman ***@***.***> wrote:
> I'd rather a def. I think people write lambdas thinking it's doing
> something different. They're wrong. Defs provide a name in the traceback.
>
> On 29 December 2016 at 08:05, (Venkat) Raghav (Rajagopalan) <
> ***@***.***> wrote:
>
>> Our flake8 checker in travis raises error for lambdas for one-liners. I
>> don't think we follow that. Most contributors might prefer lambdas
>> actually...
>>
>> Ref lambda check_df = lambda x: isinstance(x, InputFeatureType)
>> <https://github.com/scikit-learn/scikit-learn/pull/5697/files#diff-d51a9726ff1d2791c05babac47e936d5R984>
>>
>> @GaelVaroquaux <https://github.com/GaelVaroquaux> @jnothman
>> <https://github.com/jnothman> Is this fine with you?
>> ------------------------------
>> You can view, comment on, or merge this pull request online at:
>>
>> #8131
>> Commit Summary
>>
>> - MNT Ignore E731: Use a def instead of lambda
>>
>> File Changes
>>
>> - *M* build_tools/travis/flake8_diff.sh
>> <https://github.com/scikit-learn/scikit-learn/pull/8131/files#diff-0>
>> (4)
>>
>> Patch Links:
>>
>> - https://github.com/scikit-learn/scikit-learn/pull/8131.patch
>> - https://github.com/scikit-learn/scikit-learn/pull/8131.diff
>>
>> —
>> You are receiving this because you were mentioned.
>> Reply to this email directly, view it on GitHub
>> <#8131>, or mute the
>> thread
>> <https://github.com/notifications/unsubscribe-auth/AAEz688hs4q9nckh3Iq7bwejPkRRL7Aaks5rMs78gaJpZM4LXMBs>
>> .
>>
>
>
|
Okay thanks for the clarification. Now that we have that preference documented here in this PR, I'll close it... ;) |
I'd rather a def. I think people write lambdas thinking it's doing
something different. They're wrong. Defs provide a name in the traceback.
I agree. In general lambdas are to be avoided. But there are cases where
they are just much more concise.
The question of whether adding a lambda should raise an error in tests is
open. To me, these are things that should be caught in reviews, and we
should strive for having CI always green. I tend to strongly dislike
merging PRs with failing tests, as it opens the door to human error.
That just reminds me how little love I have for the pep8 tool, which is
an overly strict interpretation of the book (and was criticized as so by
Guido and hence has been renamed to "pycodestyle"
PyCQA/pycodestyle#466).
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Our flake8 checker in travis raises error for lambdas for one-liners. I don't think we follow that. Most contributors might prefer lambdas actually...
Ref
lambda check_df = lambda x: isinstance(x, InputFeatureType)
@GaelVaroquaux @jnothman @ogrisel Is this fine with you?