Skip to main content

Lib to verify types of functions

Project description

Verify types

Verifica a tipagem e os retornos das funções em python

How works ?

pip3 install verify-types

After that how use ?

To use in one method you only need the decorator validate_params

from verify_types import validate_params


@validate_params
def example(a: str, b: float) -> str:
	return f"a: {b}"

To this case is possible verify if the input and output is correct. If dont't match the types a ValueError will raise with correct type, actual type and path of an error.

To use on all class's methods

from verify_types import validate_params, decorate_all_methods                  
                                                                                
                                                                                
@decorate_all_methods(validate_params)                                          
class TestA:                                                                    
    def __init__(self, a: str) -> None:                                         
        self.a = a                                                              
                                                                                
    def print_a(self) -> None:                                                  
        print(self.a)                                                           
                                                                                
    def concat_a(self, b: str) -> str:                                          
        return self.a + b                                                       
                                                                                
    def run(self) -> None:                                                      
        self.print_a()                                                          
        print(self.concat_a("nossa"))                                           
                                                                                
                                                                                
if __name__ == "__main__":                                                      
    test = TestA("Nossa")                                                       
    test.run()

This will be decorate all class methods

Observetion

If you use the decorator You must use type hint or and error will raise.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

verify_types-1.0.5.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file verify_types-1.0.5.tar.gz.

File metadata

  • Download URL: verify_types-1.0.5.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for verify_types-1.0.5.tar.gz
Algorithm Hash digest
SHA256 3ac0f8942f3132e9d6cc9fff905d79530f83bdd106e41173d1439c3eb70e6109
MD5 a3fc4619e9caf0fc959b824cec5aae62
BLAKE2b-256 30ce2fb97d83dca2762e7041c26a9db0c97aef53bead3de2979c23fe567e1fee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page