apify-sdk-python icon indicating copy to clipboard operation
apify-sdk-python copied to clipboard

Replace usage of asserts with ValueError checks

Open vdusek opened this issue 2 years ago • 2 comments

Replace usage of asserts with ValueError checks as violation S101 suggests.

Motivation in the link.

vdusek avatar Nov 20 '23 11:11 vdusek

Good point, especially in https://github.com/apify/apify-sdk-python/blob/master/src/apify/proxy_configuration.py#L280-L282 or in the storages code it's used wrongly. But in a lot of places we use assert just as a type assertion to fool Mypy, maybe we can keep it there? Unless then the S101 rule would be too difficult to set up, in that case let's just switch to ValueErrors everywhere.

fnesveda avatar Nov 27 '23 05:11 fnesveda

But in a lot of places we use assert just as a type assertion to fool Mypy, maybe we can keep it there?

I got it, however, I suppose the use of isinstance() should have the same effect, don't you think?

vdusek avatar Nov 27 '23 07:11 vdusek