Passed
Push — master ( 18b92d...e7c449 )
by Ramon
50s queued 12s
created

barentsz._here.here()   A

Complexity

Conditions 1

Size

Total Lines 12
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 1
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
import inspect
2
from pathlib import Path
3
4
5
def here(frames_back: int = 0) -> Path:
6
    """
7
    Get the current directory from which this function is called.
8
    Args:
9
        frames_back: the number of extra frames to look back.
10
11
    Returns: the directory as a Path instance.
12
13
    """
14
    stack = inspect.stack()
15
    previous_frame = stack[1 + frames_back]
16
    return Path(previous_frame.filename).parent
17