Skip to content

Commit c65a86a

Browse files
committed
Merge branch 'remote-master'
* Resolve merge conflicts ** `src/dotenv/__init__.py` ** `src/dotenv/main.py`
2 parents 06c6d61 + 955e2a4 commit c65a86a

File tree

18 files changed

+182
-314
lines changed

18 files changed

+182
-314
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
matrix:
1111
os:
1212
- ubuntu-latest
13-
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, pypy2, pypy3]
13+
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, pypy3]
1414
steps:
1515
- uses: actions/checkout@v2
1616
- name: Set up Python ${{ matrix.python-version }}

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
66
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
12+
- The `dotenv_path` argument of `set_key` and `unset_key` now has a type of `Union[str,
13+
os.PathLike]` instead of just `os.PathLike` (#347 by [@bbc2]).
14+
15+
### Changed
16+
17+
- Require Python 3.5 or a later version. Python 2 and 3.4 are no longer supported. (#341
18+
by [@bbc2]).
19+
820
## [0.18.0] - 2021-06-20
921

1022
### Changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ without manually opening it.
141141

142142
```shell
143143
$ pip install "python-dotenv[cli]"
144-
$ dotenv set USER=foo
145-
$ dotenv set EMAIL=[email protected]
144+
$ dotenv set USER foo
145+
$ dotenv set EMAIL [email protected]
146146
$ dotenv list
147147
USER=foo
148148

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
bumpversion
2-
typing; python_version<"3.5"
32
click
43
flake8>=2.2.3
54
ipython
@@ -8,6 +7,7 @@ pytest-cov
87
pytest>=3.9
98
sh>=1.09
109
tox
10+
types-mock
1111
wheel
1212
twine
1313
portray

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ max-line-length = 120
1414
exclude = .tox,.git,docs,venv,.venv
1515

1616
[mypy]
17+
check_untyped_defs = true
1718
ignore_missing_imports = true
1819

1920
[metadata]

setup.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import io
32
from setuptools import setup
43

@@ -33,9 +32,7 @@ def read_files(files):
3332
package_data={
3433
'dotenv': ['py.typed'],
3534
},
36-
install_requires=[
37-
"typing; python_version<'3.5'",
38-
],
35+
python_requires=">=3.5",
3936
extras_require={
4037
'cli': ['click>=5.0', ],
4138
},
@@ -47,8 +44,6 @@ def read_files(files):
4744
classifiers=[
4845
'Development Status :: 5 - Production/Stable',
4946
'Programming Language :: Python',
50-
'Programming Language :: Python :: 2',
51-
'Programming Language :: Python :: 2.7',
5247
'Programming Language :: Python :: 3',
5348
'Programming Language :: Python :: 3.5',
5449
'Programming Language :: Python :: 3.6',

src/dotenv/__init__.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
from .compat import IS_TYPE_CHECKING
2-
from .main import load_dotenv, get_key, set_key, unset_key, find_dotenv, dotenv_values, update_dict_to_dotenv
1+
from typing import Any, Optional
32

4-
if IS_TYPE_CHECKING:
5-
from typing import Any, Optional
3+
from .main import (dotenv_values, find_dotenv, get_key, load_dotenv, set_key,
4+
unset_key, update_dict_to_dotenv)
65

76

8-
def load_ipython_extension(ipython):
9-
# type: (Any) -> None
7+
def load_ipython_extension(ipython: Any) -> None:
108
from .ipython import load_ipython_extension
119
load_ipython_extension(ipython)
1210

1311

14-
def get_cli_string(path=None, action=None, key=None, value=None, quote=None):
15-
# type: (Optional[str], Optional[str], Optional[str], Optional[str], Optional[str]) -> str
12+
def get_cli_string(
13+
path: Optional[str] = None,
14+
action: Optional[str] = None,
15+
key: Optional[str] = None,
16+
value: Optional[str] = None,
17+
quote: Optional[str] = None,
18+
):
1619
"""Returns a string suitable for running as a shell script.
1720
1821
Useful for converting a arguments passed to a fabric task

src/dotenv/cli.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import sys
33
from subprocess import Popen
4+
from typing import Any, Dict, List
45

56
try:
67
import click
@@ -9,13 +10,9 @@
910
'Run pip install "python-dotenv[cli]" to fix this.')
1011
sys.exit(1)
1112

12-
from .compat import IS_TYPE_CHECKING, to_env
1313
from .main import dotenv_values, get_key, set_key, unset_key
1414
from .version import __version__
1515

16-
if IS_TYPE_CHECKING:
17-
from typing import Any, List, Dict
18-
1916

2017
@click.group()
2118
@click.option('-f', '--file', default=os.path.join(os.getcwd(), '.env'),
@@ -29,8 +26,7 @@
2926
help="Whether to write the dot file as an executable bash script.")
3027
@click.version_option(version=__version__)
3128
@click.pass_context
32-
def cli(ctx, file, quote, export):
33-
# type: (click.Context, Any, Any, Any) -> None
29+
def cli(ctx: click.Context, file: Any, quote: Any, export: Any) -> None:
3430
'''This script is used to set, get or unset values from a .env file.'''
3531
ctx.obj = {}
3632
ctx.obj['QUOTE'] = quote
@@ -40,8 +36,7 @@ def cli(ctx, file, quote, export):
4036

4137
@cli.command()
4238
@click.pass_context
43-
def list(ctx):
44-
# type: (click.Context) -> None
39+
def list(ctx: click.Context) -> None:
4540
'''Display all the stored key/value.'''
4641
file = ctx.obj['FILE']
4742
if not os.path.isfile(file):
@@ -58,8 +53,7 @@ def list(ctx):
5853
@click.pass_context
5954
@click.argument('key', required=True)
6055
@click.argument('value', required=True)
61-
def set(ctx, key, value):
62-
# type: (click.Context, Any, Any) -> None
56+
def set(ctx: click.Context, key: Any, value: Any) -> None:
6357
'''Store the given key/value.'''
6458
file = ctx.obj['FILE']
6559
quote = ctx.obj['QUOTE']
@@ -74,8 +68,7 @@ def set(ctx, key, value):
7468
@cli.command()
7569
@click.pass_context
7670
@click.argument('key', required=True)
77-
def get(ctx, key):
78-
# type: (click.Context, Any) -> None
71+
def get(ctx: click.Context, key: Any) -> None:
7972
'''Retrieve the value for the given key.'''
8073
file = ctx.obj['FILE']
8174
if not os.path.isfile(file):
@@ -93,8 +86,7 @@ def get(ctx, key):
9386
@cli.command()
9487
@click.pass_context
9588
@click.argument('key', required=True)
96-
def unset(ctx, key):
97-
# type: (click.Context, Any) -> None
89+
def unset(ctx: click.Context, key: Any) -> None:
9890
'''Removes the given key.'''
9991
file = ctx.obj['FILE']
10092
quote = ctx.obj['QUOTE']
@@ -113,8 +105,7 @@ def unset(ctx, key):
113105
help="Override variables from the environment file with those from the .env file.",
114106
)
115107
@click.argument('commandline', nargs=-1, type=click.UNPROCESSED)
116-
def run(ctx, override, commandline):
117-
# type: (click.Context, bool, List[str]) -> None
108+
def run(ctx: click.Context, override: bool, commandline: List[str]) -> None:
118109
"""Run command with environment variables present."""
119110
file = ctx.obj['FILE']
120111
if not os.path.isfile(file):
@@ -123,9 +114,9 @@ def run(ctx, override, commandline):
123114
ctx=ctx
124115
)
125116
dotenv_as_dict = {
126-
to_env(k): to_env(v)
117+
k: v
127118
for (k, v) in dotenv_values(file).items()
128-
if v is not None and (override or to_env(k) not in os.environ)
119+
if v is not None and (override or k not in os.environ)
129120
}
130121

131122
if not commandline:
@@ -135,8 +126,7 @@ def run(ctx, override, commandline):
135126
exit(ret)
136127

137128

138-
def run_command(command, env):
139-
# type: (List[str], Dict[str, str]) -> int
129+
def run_command(command: List[str], env: Dict[str, str]) -> int:
140130
"""Run command in sub process.
141131
142132
Runs the command in a sub process with the variables from `env`

src/dotenv/compat.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/dotenv/ipython.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import print_function
2-
31
from IPython.core.magic import Magics, line_magic, magics_class # type: ignore
42
from IPython.core.magic_arguments import (argument, magic_arguments, # type: ignore
53
parse_argstring) # type: ignore

0 commit comments

Comments
 (0)