executiontime 0.3.2__tar.gz → 0.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: executiontime
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: A simple function decorator to display its execution time on the console or in the logs.
5
5
  License: MIT
6
6
  Keywords: testing,logging,time,performance,execution
@@ -1,8 +1,10 @@
1
1
  """
2
2
  Defines the printexecutiontime decorator
3
3
  """
4
+
4
5
  from datetime import datetime
5
6
  from functools import wraps
7
+ from typing import Any, Callable, Optional
6
8
 
7
9
  from colorama import Fore
8
10
 
@@ -23,20 +25,23 @@ RED = Fore.RED
23
25
  WHITE = Fore.WHITE
24
26
  YELLOW = Fore.YELLOW
25
27
 
26
- def printexecutiontime(message, output=print, color=None):
27
- '''
28
+
29
+ def printexecutiontime(message: str, output: Callable[..., None] = print, color: Optional[str] = None) -> Any:
30
+ """
28
31
  This function returns a decorator. This allows to have a decorator that accepts parameters.
29
32
  message: A string with a '{0}' placeholder for the time that will be sent to the console.
30
- '''
31
- def decorator(function):
32
- '''
33
+ """
34
+
35
+ def decorator(function: Callable[..., Any]) -> Any:
36
+ """
33
37
  The decorator itself returns a wrapper function that will replace the original one.
34
- '''
38
+ """
39
+
35
40
  @wraps(function)
36
- def wrapper(*args, **kwargs):
37
- '''
41
+ def wrapper(*args: Any, **kwargs: Any) -> Any:
42
+ """
38
43
  This wrapper calculates and displays the execution time of the function.
39
- '''
44
+ """
40
45
  start = datetime.utcnow()
41
46
  value = function(*args, **kwargs)
42
47
  elapsed = datetime.utcnow() - start
@@ -45,5 +50,7 @@ def printexecutiontime(message, output=print, color=None):
45
50
  msg = color + msg + Fore.RESET
46
51
  output(msg)
47
52
  return value
53
+
48
54
  return wrapper
55
+
49
56
  return decorator
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "executiontime"
3
- version = "0.3.2"
3
+ version = "0.3.3"
4
4
  description = "A simple function decorator to display its execution time on the console or in the logs."
5
5
  authors = ["Timokasse <Timokasse@users.noreply.github.com>"]
6
6
  license = "MIT"
@@ -16,9 +16,7 @@ classifiers = [
16
16
  "Topic :: Software Development :: Testing",
17
17
  ]
18
18
  keywords = ["testing", "logging", "time", "performance", "execution"]
19
- packages = [
20
- { include = "executiontime" }
21
- ]
19
+ packages = [{ include = "executiontime" }]
22
20
 
23
21
  [tool.poetry.dependencies]
24
22
  python = "^3.11"
@@ -29,7 +27,15 @@ colorama = "^0.4.6"
29
27
  pylint = "^3.0.3"
30
28
  black = "^24.2.0"
31
29
  mypy = "^1.8.0"
30
+ types-colorama = "^0.4.15.20240205"
32
31
 
33
32
  [build-system]
34
33
  requires = ["poetry-core"]
35
34
  build-backend = "poetry.core.masonry.api"
35
+
36
+ [tool.mypy]
37
+ strict = true
38
+
39
+ [tool.pylint.format]
40
+ # Maximum number of characters on a single line.
41
+ max-line-length = 160
File without changes
File without changes