Skip to content

Conversation

samertm
Copy link
Contributor

@samertm samertm commented Nov 28, 2018

  • Always short-circuit in the if's expression, instead of only
    short-circuiting for "ALWAYS_TRUE/FALSE" constants (e.g. sys.platform
    checks) and not "MYPY_TRUE/FALSE" constants (e.g. MYPY)

  • Make --always-true and --always-false map to ALWAYS_TRUE and
    ALWAYS_FALSE, respectively, instead of MYPY_TRUE and MYPY_FALSE.
    The only difference between the two is a change in import priority,
    but semantically uses of "--always-true" are probably closer to
    "this condition should be true at compile time and runtime" than
    "this condition should be true at compile time but false at
    runtime".

  • Fixes Small bug: if expression doesn't short circuit for --always-false/--always-true #5963

@samertm
Copy link
Contributor Author

samertm commented Nov 28, 2018

I haven't run or tested this locally yet, I'll do that tomorrow :o)

Copy link
Collaborator

@msullivan msullivan left a comment

Choose a reason for hiding this comment

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

This looks good! If you rebase it to fix the merge conflicts we should be good to go.

@samertm samertm force-pushed the shortcircuit branch 2 times, most recently from 6a2587f to a00906d Compare December 18, 2018 00:52
@samertm
Copy link
Contributor Author

samertm commented Dec 18, 2018

Just fixed the merge conflicts, should be ready to merge if the tests pass.

@msullivan
Copy link
Collaborator

Unfortunately they did not

…YPY/TYPE_CHECKING

 - Always short-circuit in the if's expression, instead of only
   short-circuiting for "ALWAYS_TRUE/FALSE" constants (e.g. sys.platform
   checks) and not "MYPY_TRUE/FALSE" constants (e.g. `MYPY`)

 - Make --always-true and --always-false map to ALWAYS_TRUE and
   ALWAYS_FALSE, respectively, instead of MYPY_TRUE and MYPY_FALSE.
   The only difference between the two is a change in import priority,
   but semantically uses of "--always-true" are probably closer to
   "this condition should be true at compile time and runtime" than
   "this condition should be true at compile time but false at
   runtime".

 - Fixes python#5963
@samertm
Copy link
Contributor Author

samertm commented Dec 19, 2018

Looks like tests are passing now :)

@msullivan msullivan merged commit 833517d into python:master Dec 20, 2018
@msullivan
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Small bug: if expression doesn't short circuit for --always-false/--always-true
2 participants