clkhash icon indicating copy to clipboard operation
clkhash copied to clipboard

Code formatting issues - automate?

Open hardbyte opened this issue 6 years ago • 2 comments

Consider applying black

Aha! Link: https://csiro.aha.io/features/ANONLINK-39

hardbyte avatar Apr 13 '18 01:04 hardbyte

See closed PR #110

Essentially the findings are that we can't use black (yet). The problem is we would have to change our inline type annotations for mypy. E.g. the function:

def double_hash_encode_ngrams_non_singular(ngrams,          # type: Iterable[str]
                              keys,            # type: Sequence[bytes]
                              k,               # type: int
                              l,               # type: int
                              encoding         # type: str
                              ):
    # type: (...) -> bitarray.bitarray
    """
    computes the double hash encoding of the provided n-grams with the given keys.

Formatted by black running with all defaults into:

def double_hash_encode_ngrams_non_singular(
    ngrams,
    keys,
    k,
    l,
    encoding,  # type: Iterable[str]  # type: Sequence[bytes]  # type: int  # type: int  # type: str
):
    # type: (...) -> bitarray.bitarray
    """
    computes the double hash encoding of the provided n-grams with the given keys.
    ...

Which mypy doesn't like.

hardbyte avatar Apr 13 '18 05:04 hardbyte

Black have patched to now handle type annotations so could we worth trying this again.

hardbyte avatar May 14 '19 04:05 hardbyte