As is mentioned by @sirosen in this post, pylint and flake8-bugbear provides the tool to check for these conditions and provide you a warning in your code editor (I haven’t tried them yet, but it should draw a wavy yellow line in VSCode when the conditions you configured are met).
This is not exactly the same as you requested (disallow), but should work for your use case.