Skip to content
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

Stubs: Different behavior inside "if version_check" blocks #1060

Closed
srittau opened this issue Oct 12, 2019 · 1 comment
Closed

Stubs: Different behavior inside "if version_check" blocks #1060

srittau opened this issue Oct 12, 2019 · 1 comment
Labels
F: empty lines Wasting vertical space efficiently. S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: enhancement New feature or request

Comments

@srittau
Copy link
Contributor

srittau commented Oct 12, 2019

Operating system: Debian buster
Python version: 3.7.3
Black version: 19.3b0
Does also happen on master: yes

We are currently looking into reformatting typeshed with black. One snag I ran into is in the following example:

import sys

class Foo:
    def bar(self): ...

def abc(): ...

if sys.version_info >= (3,):
    class Foo:
        def bar(self): ...

    def abc(): ...

Reformatting this with black removes the empty line between the class and the function inside the "if" block, but not outside it:

import sys

class Foo:
    def bar(self): ...

def abc(): ...

if sys.version_info >= (3,):
    class Foo:
        def bar(self): ...
    def abc(): ...

This causes some sub-module that are basically one big "if" block (since they were added in later Python versions) to be very "dense". One example is: https://github.com/python/typeshed/blob/c90b41bb230121a20e18da3adf772da1d03f7ab4/stdlib/3/importlib/metadata.pyi

@JelleZijlstra JelleZijlstra self-assigned this Oct 13, 2019
@zsol zsol added the T: enhancement New feature or request label Oct 13, 2019
@JelleZijlstra JelleZijlstra removed their assignment May 30, 2021
@JelleZijlstra JelleZijlstra added the F: empty lines Wasting vertical space efficiently. label May 30, 2021
@ichard26 ichard26 added the S: accepted The changes in this design / enhancement issue have been accepted and can be implemented label Jun 12, 2021
@hauntsaninja
Copy link
Collaborator

I think I fixed this in #2784 / #2820

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: empty lines Wasting vertical space efficiently. S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants