rsalmei / alive-progress

A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
MIT License
5.45k stars 205 forks source link

pylint complains that alive_bar contextmanager is not callable #249

Closed manvithn closed 8 months ago

manvithn commented 1 year ago

This might be a pylint issue, but on any code like this

    with alive_bar() as progress:
        for ... in ...:
                progress()

pylint-2.17.4 will give the message that progress is not callable: E1102:not-callable. I did see https://github.com/pylint-dev/pylint/issues/1746 which was closed a while ago, or it might be that we need some type hint in alive_bar.

rsalmei commented 1 year ago

Yeah, I can confirm it does. But I recommend ruff, which doesn't.

If you do want pylint however, I'm not sure how to fix it yet. This is the entrypoint for alive-progress' alive_bar:

def alive_bar(total: Optional[int] = None, *, calibrate: Optional[int] = None, **options: Any):
    return __alive_bar(config, total, calibrate=calibrate)

@contextmanager
def __alive_bar(config, total=None, *, calibrate=None,
                _cond=threading.Condition, _sampling=False, _testing=None):

Note it returns a @contextmanager, no mention of Callable indeed.

But even if I do change them to:

def alive_bar(total: Optional[int] = None, *, calibrate: Optional[int] = None, **options: Any) -> Callable:
    return __alive_bar(config, total, calibrate=calibrate)

@contextmanager
def __alive_bar(config, total=None, *, calibrate=None,
                _cond=threading.Condition, _sampling=False, _testing=None) -> Callable:

It still doesn't work on pylint (2.17.6). Any suggestions?

rsalmei commented 8 months ago

Closing this one, but feel free to reply if there's any news.