best-doctor / flake8-annotations-coverage

flake8 plugin to validate annotations coverage
MIT License
34 stars 5 forks source link

Make this plugin more flexible #8

Closed sobolevn closed 5 years ago

sobolevn commented 5 years ago

I am not sure how exactly we can achieve that, but here's my problem:

# some.py

def untyped(arg):
    ...

def typed(arg: int) -> int:
    ...

As you can see the ratio of typed/untyped is 50/50 in this case. And I only have two functions here. But, this plugin reports this file as invalid.

What have I tried?

  1. Reducing the global setting of typed code, but that is bad for my other files and overall quality. So, I won't do that
  2. Ignore this file in the setup.cfg, this does not work as well. Since, now I allow all other functions in this module to be untyped. That's not what I want.

What I seek is a some kind of setting to resolve this situation: like "Too few items to analyse" or similar.

Melevir commented 5 years ago

Adding such option allows code to stay untyped, this is not ok for me. Consider these options:

  1. Annotate unannotated functions :) This is what this plugin for, after all.

  2. Use partial annotation like annotating only one argument or only return type. It's better than nothing.

  3. Use dummy annotation -> Any. This looks like bullshit, but it makes mypy to threat function as annotated and validate its body. Nice and easy start.

I'm thinking about adding --strict option for projects, that already annotated all code with options 4 and 5 and need to move to 3.