This is a feature PHP has had since PHP7 and is what I use all the time with PHP. It works on a file by file basis (I guess for backward compatibility), a declare line needs to be at the top of a file `declare(strict_types=1);` If this line is at the top of the file, then a TypeError is thrown on any method/function that uses type hints in the current file if the passed arg or return value is the wrong type. Here is more info: https://dev.to/robdwaller/how-php-type-declarations-actually-work-1mm5
I would like to see this PHP feature in Python. A strict types declaration line can be added at the top any file or/and it could be set globally at the start of the script by doing something like `sys.strict_types = True`. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/DS75G2KVPSH62JZMMFDUKPBTLM5CIJ5K/ Code of Conduct: http://python.org/psf/codeofconduct/