Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Landscape falsely reports an access to protected members. #261

Closed
Paebbels opened this issue Dec 5, 2016 · 1 comment
Closed

Landscape falsely reports an access to protected members. #261

Paebbels opened this issue Dec 5, 2016 · 1 comment

Comments

@Paebbels
Copy link

Paebbels commented Dec 5, 2016

Landscape.io reports accesses to protected members, but these members are visible in the class, because the passed method parameter is an instance of the class itself, and thus all protected members are visible.

The reported message is:

pylint: protected-access (W0212)
ToolMixIn.init(self, toolchain._platform, toolchain._dryrun, toolchain._binaryDirectoryPath, toolchain._version, toolchain._logger)
Access to a protected member _logger of a client class
Access to a protected member _version of a client class
Access to a protected member _binaryDirectoryPath of a client class
Access to a protected member _dryrun of a client class
Access to a protected member _platform of a client class

Full Landscape.io report: .../Aldec/ActiveHDL.py#L227

I have this factory code:

class Executable:
  pass

class ToolMixIn:
  def __init__(self, platform, dryrun, binaryDirectoryPath, version, logger=None):
    self._platform =            platform
    self._dryrun =              dryrun
    self._binaryDirectoryPath = binaryDirectoryPath
    self._version =             version
    self._logger =              logger

class ActiveHDL(ToolMixIn):
  """Factory for executable abstractions in Active-HDL."""
  def GetVHDLCompiler(self):
    """Return an instance of Active-HDL's VHDL compiler 'vcom'."""
    return VHDLCompiler(self)

class VHDLCompiler(Executable, ToolMixIn):
  """Abstraction layer of Active-HDL's VHDL compiler 'vcom'."""
  def __init__(self, toolchain : ToolMixIn):
    ToolMixIn.__init__(self, toolchain._platform, toolchain._dryrun, toolchain._binaryDirectoryPath, toolchain._version, toolchain._logger)
    # ...

Please note, the factory ActiveHDL as well as the created object VHDLCompiler derive from ToolMixIn.

According to visibility rules of object oriented programming, this is valid code. The code checker in PyCharm doesn't complain about this code since I added a type hint: : ToolMixIn.


Related issues:

@Paebbels
Copy link
Author

Any updates on that issue?

@carlio carlio closed this as completed Dec 31, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants