Home > Software design >  Explain DeprecationWarning: private variables, such as '_Cmd__call_set', will be normal at
Explain DeprecationWarning: private variables, such as '_Cmd__call_set', will be normal at

Time:11-11

Python interpreter version used in the code base I am working on has recently been updated from Python 3.7 to 3.9.

A few new warnings similar to one in the title have started showing up when some of the tools written in Python are executed.

I've searched the net extensively, read the What's New in 3.10 but haven't found an answer about what it exactly means, and what possible actions I can take to address it. I have an option to grep the source code of CPython of course, but I'd rather avoid it if possible.

The warning seems to predict change in the visibility of class members. The code in question was not written by me. The original author is (of course) no longer available. Personally, I never use underscored members in an attempt to affect their visibility.

Here is how the code around the warning looks like:

class Cmd(Enum):
    ...
    @classmethod
    def __call_set(cls, # << Here the warning
            ...):
        ...

CodePudding user response:

writing an attribute as so: _attr makes it a private attribute, and __attr makes it a protected attribute. This deprecation warning seems to indicate the attributes in question will be made not private and not protected in 3.10.

TL;DR

They won't have the underscore in 3.10, and they will be completely visible.

  • Related