3 ms·
I see this often and it is a bad pattern that people do. Typically type checked languages wouldn't even allow you to do. If you would use mypy for type checkin
by takeda 7y ago
I see this often and it is a bad pattern that people do.
Typically type checked languages wouldn't even allow you to do. If you would use mypy for type checking it wouldn't like it because you're redefining the type of a variable. Best practices would suggest you use a different variable for the conversion if you must, but ideally you should just make the function accept list as an argument. If you're really worried about passing something else than a list, you should use type annotations to tell type checker what it is. If you want to add extra runtime check then do:
assert isinstance(group_keys, list)
You can complain that Python allowed you to something dangerous, but you have tools to help you avoid it and this flexibility is what makes tools like SQLAlchemy so powerful.