From 0ef5d1d7ad28ba2f85bc147cbe37b67d9f49975c Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Date: Fri, 30 Jul 2021 09:18:56 +0300 Subject: [PATCH 1/5] Disable universal newlines when reading TOML --- Pipfile | 2 +- Pipfile.lock | 14 +++++++------- setup.py | 2 +- src/black/files.py | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Pipfile b/Pipfile index 433a3b392f7..f7fb6da2e0f 100644 --- a/Pipfile +++ b/Pipfile @@ -31,7 +31,7 @@ click = ">=8.0.0" mypy_extensions = ">=0.4.3" pathspec = ">=0.8.1" regex = ">=2020.1.8" -tomli = ">=0.2.6, <2.0.0" +tomli = ">=1.1.0, <2.0.0" typed-ast = "==1.4.2" typing_extensions = {"python_version <" = "3.10","version >=" = "3.10.0.0"} black = {editable = true,extras = ["d"],path = "."} diff --git a/Pipfile.lock b/Pipfile.lock index 3047a487657..cd8507cdd98 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "a02de7783dc48a2466cf52fc639b76f39823ccc87cee228521905f5fdb830b1f" + "sha256": "9beecb30bc5af307b7c564b242826c3838a2a5090b94c25c579a4fa79c4c6ebc" }, "pipfile-spec": 6, "requires": {}, @@ -655,11 +655,11 @@ }, "identify": { "hashes": [ - "sha256:242332b3bdd45a8af1752d5d5a3afb12bee26f8e67c4be06e394f82d05ef1a4d", - "sha256:a510cbe155f39665625c8a4c4b4f9360cbce539f51f23f47836ab7dd852db541" + "sha256:7199679b5be13a6b40e6e19ea473e789b11b4e3b60986499b1f589ffb03c217c", + "sha256:7bc6e829392bd017236531963d2d937d66fc27cadc643ac0aba2ce9f26157c79" ], "markers": "python_full_version >= '3.6.1'", - "version": "==2.2.12" + "version": "==2.2.13" }, "idna": { "hashes": [ @@ -900,11 +900,11 @@ }, "pre-commit": { "hashes": [ - "sha256:764972c60693dc668ba8e86eb29654ec3144501310f7198742a767bec385a378", - "sha256:b679d0fddd5b9d6d98783ae5f10fd0c4c59954f375b70a58cbe1ce9bcf9809a4" + "sha256:2386eeb4cf6633712c7cc9ede83684d53c8cafca6b59f79c738098b51c6d206c", + "sha256:ec3045ae62e1aa2eecfb8e86fa3025c2e3698f77394ef8d2011ce0aedd85b2d4" ], "index": "pypi", - "version": "==2.13.0" + "version": "==2.14.0" }, "pycodestyle": { "hashes": [ diff --git a/setup.py b/setup.py index 92b78f1abe1..fab3e1edc44 100644 --- a/setup.py +++ b/setup.py @@ -74,7 +74,7 @@ def get_long_description() -> str: install_requires=[ "click>=7.1.2", "platformdirs>=2", - "tomli>=0.2.6,<2.0.0", + "tomli>=1.1.0,<2.0.0", "typed-ast>=1.4.2; python_version < '3.8'", "regex>=2020.1.8", "pathspec>=0.8.1, <1", diff --git a/src/black/files.py b/src/black/files.py index ba60c84a275..157beaada31 100644 --- a/src/black/files.py +++ b/src/black/files.py @@ -92,8 +92,8 @@ def parse_pyproject_toml(path_config: str) -> Dict[str, Any]: If parsing fails, will raise a tomli.TOMLDecodeError """ - with open(path_config, encoding="utf8") as f: - pyproject_toml = tomli.load(f) # type: ignore # due to deprecated API usage + with open(path_config, "rb") as f: + pyproject_toml = tomli.load(f) config = pyproject_toml.get("tool", {}).get("black", {}) return {k.replace("--", "").replace("-", "_"): v for k, v in config.items()} From 5b63db75440a0bd530d3ad1a5ad1a5d2f39ddb52 Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Date: Fri, 30 Jul 2021 16:51:00 +0300 Subject: [PATCH 2/5] Add changelog entry --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index a678aaefc2a..d840d3ca907 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ ### _Black_ - Add support for formatting Jupyter Notebook files (#2357) +- Do not accept bare carriage return line endings in pyproject.toml (#2408) - Move from `appdirs` dependency to `platformdirs` (#2375) ## 21.7b0 From ed57a8c51348e897ba64e68fabc01ccd25d740bc Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Date: Sat, 7 Aug 2021 00:19:48 +0300 Subject: [PATCH 3/5] Undo lockfile changes --- Pipfile.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Pipfile.lock b/Pipfile.lock index cd8507cdd98..3047a487657 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "9beecb30bc5af307b7c564b242826c3838a2a5090b94c25c579a4fa79c4c6ebc" + "sha256": "a02de7783dc48a2466cf52fc639b76f39823ccc87cee228521905f5fdb830b1f" }, "pipfile-spec": 6, "requires": {}, @@ -655,11 +655,11 @@ }, "identify": { "hashes": [ - "sha256:7199679b5be13a6b40e6e19ea473e789b11b4e3b60986499b1f589ffb03c217c", - "sha256:7bc6e829392bd017236531963d2d937d66fc27cadc643ac0aba2ce9f26157c79" + "sha256:242332b3bdd45a8af1752d5d5a3afb12bee26f8e67c4be06e394f82d05ef1a4d", + "sha256:a510cbe155f39665625c8a4c4b4f9360cbce539f51f23f47836ab7dd852db541" ], "markers": "python_full_version >= '3.6.1'", - "version": "==2.2.13" + "version": "==2.2.12" }, "idna": { "hashes": [ @@ -900,11 +900,11 @@ }, "pre-commit": { "hashes": [ - "sha256:2386eeb4cf6633712c7cc9ede83684d53c8cafca6b59f79c738098b51c6d206c", - "sha256:ec3045ae62e1aa2eecfb8e86fa3025c2e3698f77394ef8d2011ce0aedd85b2d4" + "sha256:764972c60693dc668ba8e86eb29654ec3144501310f7198742a767bec385a378", + "sha256:b679d0fddd5b9d6d98783ae5f10fd0c4c59954f375b70a58cbe1ce9bcf9809a4" ], "index": "pypi", - "version": "==2.14.0" + "version": "==2.13.0" }, "pycodestyle": { "hashes": [ From 4954e4866485798927b6da2969a170b97cb3da8f Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Date: Sun, 5 Dec 2021 11:40:30 +0200 Subject: [PATCH 4/5] Allow Tomli v2 in the future --- Pipfile | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Pipfile b/Pipfile index 12065abeb1a..90d4a2a78c1 100644 --- a/Pipfile +++ b/Pipfile @@ -42,7 +42,7 @@ platformdirs= ">=2" click = ">=8.0.0" mypy_extensions = ">=0.4.3" pathspec = ">=0.8.1" -tomli = ">=1.1.0, <2.0.0" +tomli = ">=1.1.0, <3.0.0" typed-ast = "==1.4.3" typing_extensions = {markers = "python_version < '3.10'", version = ">=3.10.0.0"} black = {editable = true,extras = ["d"],path = "."} diff --git a/setup.py b/setup.py index e6177982135..d314bb283f2 100644 --- a/setup.py +++ b/setup.py @@ -99,7 +99,7 @@ def find_python_files(base: Path) -> List[Path]: install_requires=[ "click>=7.1.2", "platformdirs>=2", - "tomli>=1.1.0,<2.0.0", + "tomli>=1.1.0,<3.0.0", "typed-ast>=1.4.2; python_version < '3.8' and implementation_name == 'cpython'", "pathspec>=0.9.0, <1", "dataclasses>=0.6; python_version < '3.7'", From 60ef6f081676901caebb0823b735479a1c0f1936 Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Date: Sun, 5 Dec 2021 11:41:51 +0200 Subject: [PATCH 5/5] Fix changelog entry location --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 7e37a68e6ee..02c2159eec9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ ### _Black_ +- Do not accept bare carriage return line endings in pyproject.toml (#2408) - Fix determination of f-string expression spans (#2654) - Fix bad formatting of error messages about EOF in multi-line statements (#2343) - Functions and classes in blocks now have more consistent surrounding spacing (#2472) @@ -94,7 +95,6 @@ ### _Black_ - Add support for formatting Jupyter Notebook files (#2357) -- Do not accept bare carriage return line endings in pyproject.toml (#2408) - Move from `appdirs` dependency to `platformdirs` (#2375) - Present a more user-friendly error if .gitignore is invalid (#2414) - The failsafe for accidentally added backslashes in f-string expressions has been