Path 1: 54 calls (0.93)

None (54)

False (54)

1def load_dotenv(path: str | os.PathLike | None = None) -> bool:
2    """Load "dotenv" files in order of precedence to set environment variables.
3
4    If an env var is already set it is not overwritten, so earlier files in the
5    list are preferred over later files.
6
7    This is a no-op if `python-dotenv`_ is not installed.
8
9    .. _python-dotenv: https://github.com/theskumar/python-dotenv#readme
10
11    :param path: Load the file at this location instead of searching.
12    :return: ``True`` if a file was loaded.
13
14    .. versionchanged:: 2.0
15        The current directory is not changed to the location of the
16        loaded file.
17
18    .. versionchanged:: 2.0
19        When loading the env files, set the default encoding to UTF-8.
20
21    .. versionchanged:: 1.1.0
22        Returns ``False`` when python-dotenv is not installed, or when
23        the given path isn't a file.
24
25    .. versionadded:: 1.0
26    """
27    try:
28        import dotenv
29    except ImportError:
30        if path or os.path.isfile(".env") or os.path.isfile(".flaskenv"):
31            click.secho(
32                " * Tip: There are .env or .flaskenv files present."
33                ' Do "pip install python-dotenv" to use them.',
34                fg="yellow",
35                err=True,
36            )
37
38        return False
39
40    # Always return after attempting to load a given path, don't load
41    # the default files.
42    if path is not None:
43        if os.path.isfile(path):
44            return dotenv.load_dotenv(path, encoding="utf-8")
45
46        return False
47
48    loaded = False
49
50    for name in (".env", ".flaskenv"):
51        path = dotenv.find_dotenv(name, usecwd=True)
52
53        if not path:
54            continue
55
56        dotenv.load_dotenv(path, encoding="utf-8")
57        loaded = True
58
59    return loaded  # True if at least one file was located and loaded.
            

Path 2: 1 calls (0.02)

None (1)

True (1)

1def load_dotenv(path: str | os.PathLike | None = None) -> bool:
2    """Load "dotenv" files in order of precedence to set environment variables.
3
4    If an env var is already set it is not overwritten, so earlier files in the
5    list are preferred over later files.
6
7    This is a no-op if `python-dotenv`_ is not installed.
8
9    .. _python-dotenv: https://github.com/theskumar/python-dotenv#readme
10
11    :param path: Load the file at this location instead of searching.
12    :return: ``True`` if a file was loaded.
13
14    .. versionchanged:: 2.0
15        The current directory is not changed to the location of the
16        loaded file.
17
18    .. versionchanged:: 2.0
19        When loading the env files, set the default encoding to UTF-8.
20
21    .. versionchanged:: 1.1.0
22        Returns ``False`` when python-dotenv is not installed, or when
23        the given path isn't a file.
24
25    .. versionadded:: 1.0
26    """
27    try:
28        import dotenv
29    except ImportError:
30        if path or os.path.isfile(".env") or os.path.isfile(".flaskenv"):
31            click.secho(
32                " * Tip: There are .env or .flaskenv files present."
33                ' Do "pip install python-dotenv" to use them.',
34                fg="yellow",
35                err=True,
36            )
37
38        return False
39
40    # Always return after attempting to load a given path, don't load
41    # the default files.
42    if path is not None:
43        if os.path.isfile(path):
44            return dotenv.load_dotenv(path, encoding="utf-8")
45
46        return False
47
48    loaded = False
49
50    for name in (".env", ".flaskenv"):
51        path = dotenv.find_dotenv(name, usecwd=True)
52
53        if not path:
54            continue
55
56        dotenv.load_dotenv(path, encoding="utf-8")
57        loaded = True
58
59    return loaded  # True if at least one file was located and loaded.
            

Path 3: 1 calls (0.02)

'non-existent-file' (1)

False (1)

1def load_dotenv(path: str | os.PathLike | None = None) -> bool:
2    """Load "dotenv" files in order of precedence to set environment variables.
3
4    If an env var is already set it is not overwritten, so earlier files in the
5    list are preferred over later files.
6
7    This is a no-op if `python-dotenv`_ is not installed.
8
9    .. _python-dotenv: https://github.com/theskumar/python-dotenv#readme
10
11    :param path: Load the file at this location instead of searching.
12    :return: ``True`` if a file was loaded.
13
14    .. versionchanged:: 2.0
15        The current directory is not changed to the location of the
16        loaded file.
17
18    .. versionchanged:: 2.0
19        When loading the env files, set the default encoding to UTF-8.
20
21    .. versionchanged:: 1.1.0
22        Returns ``False`` when python-dotenv is not installed, or when
23        the given path isn't a file.
24
25    .. versionadded:: 1.0
26    """
27    try:
28        import dotenv
29    except ImportError:
30        if path or os.path.isfile(".env") or os.path.isfile(".flaskenv"):
31            click.secho(
32                " * Tip: There are .env or .flaskenv files present."
33                ' Do "pip install python-dotenv" to use them.',
34                fg="yellow",
35                err=True,
36            )
37
38        return False
39
40    # Always return after attempting to load a given path, don't load
41    # the default files.
42    if path is not None:
43        if os.path.isfile(path):
44            return dotenv.load_dotenv(path, encoding="utf-8")
45
46        return False
47
48    loaded = False
49
50    for name in (".env", ".flaskenv"):
51        path = dotenv.find_dotenv(name, usecwd=True)
52
53        if not path:
54            continue
55
56        dotenv.load_dotenv(path, encoding="utf-8")
57        loaded = True
58
59    return loaded  # True if at least one file was located and loaded.
            

Path 4: 1 calls (0.02)

PosixPath (1)

True (1)

1def load_dotenv(path: str | os.PathLike | None = None) -> bool:
2    """Load "dotenv" files in order of precedence to set environment variables.
3
4    If an env var is already set it is not overwritten, so earlier files in the
5    list are preferred over later files.
6
7    This is a no-op if `python-dotenv`_ is not installed.
8
9    .. _python-dotenv: https://github.com/theskumar/python-dotenv#readme
10
11    :param path: Load the file at this location instead of searching.
12    :return: ``True`` if a file was loaded.
13
14    .. versionchanged:: 2.0
15        The current directory is not changed to the location of the
16        loaded file.
17
18    .. versionchanged:: 2.0
19        When loading the env files, set the default encoding to UTF-8.
20
21    .. versionchanged:: 1.1.0
22        Returns ``False`` when python-dotenv is not installed, or when
23        the given path isn't a file.
24
25    .. versionadded:: 1.0
26    """
27    try:
28        import dotenv
29    except ImportError:
30        if path or os.path.isfile(".env") or os.path.isfile(".flaskenv"):
31            click.secho(
32                " * Tip: There are .env or .flaskenv files present."
33                ' Do "pip install python-dotenv" to use them.',
34                fg="yellow",
35                err=True,
36            )
37
38        return False
39
40    # Always return after attempting to load a given path, don't load
41    # the default files.
42    if path is not None:
43        if os.path.isfile(path):
44            return dotenv.load_dotenv(path, encoding="utf-8")
45
46        return False
47
48    loaded = False
49
50    for name in (".env", ".flaskenv"):
51        path = dotenv.find_dotenv(name, usecwd=True)
52
53        if not path:
54            continue
55
56        dotenv.load_dotenv(path, encoding="utf-8")
57        loaded = True
58
59    return loaded  # True if at least one file was located and loaded.
            

Path 5: 1 calls (0.02)

None (1)

False (1)

ModuleNotFoundError (1)

1def load_dotenv(path: str | os.PathLike | None = None) -> bool:
2    """Load "dotenv" files in order of precedence to set environment variables.
3
4    If an env var is already set it is not overwritten, so earlier files in the
5    list are preferred over later files.
6
7    This is a no-op if `python-dotenv`_ is not installed.
8
9    .. _python-dotenv: https://github.com/theskumar/python-dotenv#readme
10
11    :param path: Load the file at this location instead of searching.
12    :return: ``True`` if a file was loaded.
13
14    .. versionchanged:: 2.0
15        The current directory is not changed to the location of the
16        loaded file.
17
18    .. versionchanged:: 2.0
19        When loading the env files, set the default encoding to UTF-8.
20
21    .. versionchanged:: 1.1.0
22        Returns ``False`` when python-dotenv is not installed, or when
23        the given path isn't a file.
24
25    .. versionadded:: 1.0
26    """
27    try:
28        import dotenv
29    except ImportError:
30        if path or os.path.isfile(".env") or os.path.isfile(".flaskenv"):
31            click.secho(
32                " * Tip: There are .env or .flaskenv files present."
33                ' Do "pip install python-dotenv" to use them.',
34                fg="yellow",
35                err=True,
36            )
37
38        return False
39
40    # Always return after attempting to load a given path, don't load
41    # the default files.
42    if path is not None:
43        if os.path.isfile(path):
44            return dotenv.load_dotenv(path, encoding="utf-8")
45
46        return False
47
48    loaded = False
49
50    for name in (".env", ".flaskenv"):
51        path = dotenv.find_dotenv(name, usecwd=True)
52
53        if not path:
54            continue
55
56        dotenv.load_dotenv(path, encoding="utf-8")
57        loaded = True
58
59    return loaded  # True if at least one file was located and loaded.