Re: Typing, how come that :int is not ensuring int parameter?

2020-06-11 Thread DL Neil via Python-list
On 12/06/20 9:32 AM, zljubi...@gmail.com wrote: OK, as I can see nothing is enforced but I can use mypy and tests for the purpose. Exactly! Well done - Python uses 'duck typing' and thus when the Typing module was added, it became an option. As mentioned elsewhere, it provides "hints" at

Re: Typing, how come that :int is not ensuring int parameter?

2020-06-11 Thread zljubisic
OK, as I can see nothing is enforced but I can use mypy and tests for the purpose. As I am using pycharm, looks like I need a plugin for mypy. There are two of them out there: non official: https://plugins.jetbrains.com/plugin/11086-mypy and official:

Re: Typing, how come that :int is not ensuring int parameter?

2020-06-11 Thread DL Neil via Python-list
On 12/06/20 8:51 AM, zljubi...@gmail.com wrote: Hi, If I run this code: class Property: def __init__(self, var: int): self.a: int = var @property def a(self): return self.__a @a.setter def a(self, var: int): if var > 0 and var % 2 == 0:

Re: Typing, how come that :int is not ensuring int parameter?

2020-06-11 Thread Barry Scott
> On 11 Jun 2020, at 21:51, zljubi...@gmail.com wrote: > > Hi, > > If I run this code: > class Property: > >def __init__(self, var: int): >self.a: int = var > >@property >def a(self): >return self.__a > >@a.setter >def a(self, var: int): >if var

Typing, how come that :int is not ensuring int parameter?

2020-06-11 Thread zljubisic
Hi, If I run this code: class Property: def __init__(self, var: int): self.a: int = var @property def a(self): return self.__a @a.setter def a(self, var: int): if var > 0 and var % 2 == 0: self.__a = var else: self.__a