Skip to main content

Useful decorators for your application.

Project description

DecMore

This library contains some decorators that will be useful for both daily development and application needs.

Decorators

CheckTypes:

This decorator checks if the types of the variables sent are the same as the ones the function needs

Example:

from DecMore import CheckTypes


@CheckTypes
def func(var1: str, var2: list, var3: list | tuple):
    ...


if __name__ == "__main__":
    func(1, [], var3=None)

    """ The execution will return a TypeError like this
    
    TypeError: 
    Param 'var1' Expected <class 'str'>, got <class 'int'> instead
    Param 'var3' Expected <class 'list'> or <class 'tuple'>, got <class 'NoneType'> instead
    
    """

Profiler:

This decorator shows how long each line of your function took to execute

Example:

from time import sleep
from DecMore import Profiler


@Profiler()
def func():
    sleep(10)


if __name__ == "__main__":
    func()

    """ The execution will show the data on the console like this
    
     3 function calls in 10.009 seconds
  
     Ordered by: internal time
  
     ncalls  tottime  percall  cumtime  percall filename:lineno(function)
          1   10.009   10.009   10.009   10.009 {built-in method time.sleep}
          1    0.000    0.000   10.009   10.009 main.py:4(func)
          1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
    """

Authors

Daniel Relvas Trivelli

License

This project is under the MIT license. See the file LICENSE for more details.

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

decmore-0.1.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

decmore-0.1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file decmore-0.1.1.tar.gz.

File metadata

  • Download URL: decmore-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for decmore-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7176691c95a167a964c65ecf150dad9bf9f41b2fa350c6e4ed77334c1ad98fba
MD5 b5452b7d818dbcc795c546515a950faf
BLAKE2b-256 74e74b18d83b69c059b019a92d31da9a0c6837992fa3caee2feca3b712fe3512

See more details on using hashes here.

File details

Details for the file decmore-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: decmore-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for decmore-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 885c8b212dd3768ec36665c7bd423033f98ab0adf55aa278fe1c4e87a99e8c2d
MD5 e3e62c1a33af0563ae1fd622df61b49f
BLAKE2b-256 b34a69a28734e1804329ccbe3cf787daf159b2ed3f2bc951ab50cc7e79f6e317

See more details on using hashes here.

Supported by

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