You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mypy is thorwing errors at properties that are properly defined (unless I am mistaken).
Here is my code:
fromfs.sshfsimportSSHFSclassSMS:
_USER_DEFAULT: str="xxx"_PASSWORD_DEFAULT: str="xxx"_PORT_DEFAULT: int=22def__init__(
self,
host: str,
user: str=_USER_DEFAULT,
password: str=_PASSWORD_DEFAULT,
port: int=_PORT_DEFAULT,
):
self._host: str=""self._user: str=""self._password: str=""self._port: int=0self.host=hostself.user=userself.password=passwordself.port=port@propertydefsshfs(self) ->SSHFS:
returnSSHFS(
host=self.host, user=self.user, passwd=self.password, port=self.port
)
@propertydefhost(self) ->str:
returnself._host@propertydefuser(self) ->str:
returnself._user@propertydefpassword(self) ->str:
returnself._password@propertydefport(self) ->int:
returnself._port@host.setterdefhost(self, host: str) ->None:
ifnotisinstance(host, str):
raiseTypeError("Host must be a string!")
self._host=host@user.setterdefuser(self, user: str) ->None:
ifnotisinstance(user, str):
raiseTypeError("User should be a string!")
self._user=user@password.setterdefpassword(self, password: str) ->None:
ifnotisinstance(password, str):
raiseTypeError("Password must be a string!")
self._password=password@port.setterdefport(self, port: int) ->None:
ifnotisinstance(port, int) orport<21:
raiseTypeError("Port number must be an integer and above 20!")
self._port=port
To Reproduce
mypy <the pasted code file>
Rsult:
mycodefile.py:55: error: Property "host" defined in "SMS" is read-only
mycodefile.py:56: error: Property "user" defined in "SMS" is read-only
mycodefile.py:57: error: Property "password" defined in "SMS" is read-only
mycodefile.py:58: error: Property "port" defined in "SMS" is read-only
mycodefile.py:117: error: Name "host" already defined on line 73
mycodefile.py:117: error: "Callable[[SMS], str]" has no attribute "setter"
mycodefile.py:135: error: Name "user" already defined on line 84
mycodefile.py:135: error: "Callable[[SMS], str]" has no attribute "setter"
mycodefile.py:153: error: Name "password" already defined on line 95
mycodefile.py:153: error: "Callable[[SMS], str]" has no attribute "setter"
mycodefile.py:171: error: Name "port" already defined on line 106
mycodefile.py:171: error: "Callable[[SMS], int]" has no attribute "setter"
Found 12 errors in 1 file (checked 5 source files)
Your Environment
Mypy version used: 0.941
Mypy command-line flags: none
Mypy configuration options from mypy.ini (and other config files):
Python version used: 3.8.13
Operating system and version: macOS 12.2
The text was updated successfully, but these errors were encountered:
Bug Report
mypy
is thorwing errors at properties that are properly defined (unless I am mistaken).Here is my code:
To Reproduce
Rsult:
Your Environment
0.941
mypy.ini
(and other config files):3.8.13
The text was updated successfully, but these errors were encountered: