Workaround for debug python console evaluating all class properties?

I use PyCharm to test a website using playwright and custom page object models I've written. My classes have many properties for getting values from the displayed page. I often set breakpoints in my code to see the state of the website and determine ways to find and interact with elements.

I'm running PyCharm version 2022.3.3, and because of, when I use the debug console, every property is evaluated when I try to interact with my page object. This is not only extremely slow, but causes side effects in the page and has completely derailed my ability to create and debug my tests.

Are there any workarounds for this issue so that I can continue developing my tests in PyCharm?


Unfortunately, I'm not aware of the workaround. Could you please specify which side effects does evaluation of properties have?

As I understand, the best practice for using properties is that the code under the `@property` decorator should only access and return values, not modify something. When you need to modify something, it is better to use methods instead.

I thought I posted a response, but I don't see it -- basically, my class has a large number of properties that require interaction with elements on a web page. Reloading all of them is expensive.

It's also worth noting that because I interact with a web page and external servers, it took me a long time to determine that the issues I was having were related this change in PyCharm, and not something wrong with my tests or the systems I was testing.


I have this problem as well and am looking for a workaround. My classes interact with an API of another provider, and each @property method performs a GET to the provider's API. When I instantiate a class, PyCharm evaluates all of the properties, which performs hundreds of GET calls to the API, even though I don't need or care about the values of those properties until I access them. I have my "Variables Loading Policy" in the PyCharm Python Console set to "On Demand", which I think should affect this behavior, but it doesn't.

Additionally, when typing in the Python Console, PyCharm continues to evaluate these properties over and over. For example, I have a class called User with a @property method called "phone_number(self)" and a non-property method called "get_user_location()". When I start typing something like "user_instance.get_user_location()", as soon as I get to the dot after the user_instance, PyCharm starts evaluating all of the properties, likely for command completion help, which means it does the API GET for the "phone_number" property, even though I have no need for it.


One workaround I can suggest is to convert the property to a getter method, which may be better when doing something like an API call.


I agree with the workaround, but this is a PyCharm problem only and I don't want to refactor thousands of lines of code just to handle a PyCharm "feature" that should be able to be turned off. People consuming my module in VS or other IDEs don't have the same experience, and I feel like JetBrains could put a "Don't evaluate properties" option in the Python Console, or even put the evaluation code behind the existing "Variable Loading Policy", which seems to make more sense anyway.

There actually is a better workaround, which is to disable "Auto-display runtime code completion" in the Console settings, but I like the code completion; it just doesn't need to evaluate a property in order to know the property is there for completion.


Kctrey Yes, I agree that it's a PyCharm problem. There are two related issues:

The option you mentioned only solves the first one. For the second one, I'm not sure there's a workaround in the IDE. Please support the issue with your vote and sorry for the inconvenience.


Please sign in to leave a comment.