Open tooptoop4 opened 7 months ago
Do you think the rule could be generalized to disallow method calls on any object defined in a context expression after the with
statement?
@MichaReiser no, you can safely use many objects after their context is exited :) we'd need type-inference for that to be broadly correct.
For example with with pytest.raises() as exc_info
you have to use the object after the context is exited.
We would probably need to make this specific to open
calls (which would be okay).
https://github.com/wemake-services/wemake-python-styleguide?tab=readme-ov-file finds this
flake8 --select WPS441 somefile.py
ruff does not complain about:
but python does: