GHC 2018-12-20

1 comment.

, https://git.io/fhvRy in ambv/black
Inconsistent spacing around top level functions
===============================================

Operating system: macOS 10.14.2
Python version: 3.7.1
*Black* version: 18.9b0
Does also happen on master: yes

---

I have a bit of OS-specific code that looks like this (when formatted by black):

```py
import os

if os.name == "posix":
    import termios

    def foo():
        pass


elif os.name == "nt":
    try:
        import msvcrt

        def foo():
            pass

    except ImportError:

        def foo():
            pass


else:

    def foo():
        pass


other_code()
```

Note now `foo` has two empty lines below it most of the time (including in `if..elif..else`), except in the `try` block of a `try..except`.

Is this intentional? Seems to me there's no need to waste an extra line when the function definition is in any block; one empty line should be enough.