Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tool doesn't honor black preferences #62

Closed
jaraco opened this issue Nov 29, 2020 · 5 comments
Closed

Tool doesn't honor black preferences #62

jaraco opened this issue Nov 29, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@jaraco
Copy link

jaraco commented Nov 29, 2020

I've adopted blacken-docs as a pre-commit hook on my projects, but today blacken-docs gave me trouble by performing string normalization where I prefer it not be:

pip-run master $ git clone gh://jaraco/pip-run
Cloning into 'pip-run'...
remote: Enumerating objects: 466, done.
remote: Counting objects: 100% (466/466), done.
remote: Compressing objects: 100% (265/265), done.
remote: Total 1785 (delta 278), reused 369 (delta 193), pack-reused 1319
Receiving objects: 100% (1785/1785), 290.69 KiB | 4.21 MiB/s, done.
Resolving deltas: 100% (1050/1050), done.
pip-run master $ cd pip-run
pip-run master $ git checkout d17b4e8
Note: switching to 'd17b4e8'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at d17b4e8 Improve syntax in readme
pip-run HEAD $ pre-commit install
pre-commit installed at .git/hooks/pre-commit
pip-run HEAD $ pre-commit run
black................................................(no files to check)Skipped
blacken-docs.........................................(no files to check)Skipped
pip-run HEAD $ pre-commit run --all
black....................................................................Passed
blacken-docs.............................................................Failed
- hook id: blacken-docs
- exit code: 1
- files were modified by this hook

README.rst: Rewriting...

pip-run HEAD $ git diff
diff --git a/README.rst b/README.rst
index 87c34d9..6fa9b2e 100644
--- a/README.rst
+++ b/README.rst
@@ -177,11 +177,11 @@ First, add a ``__requires__`` directive at the head of the script:
 
     #!/usr/bin/env python
 
-    __requires__ = ['requests']
+    __requires__ = ["requests"]
 
     import requests
 
-    req = requests.get('https://pypi.org/project/pip-run')
+    req = requests.get("https://pypi.org/project/pip-run")
     print(req.status_code)
 
 Then, simply invoke that script with pip-run::
@@ -199,10 +199,11 @@ allowing a script to specify a custom package index:
 
     #!/usr/bin/env python
 
-    __requires__ = ['my_private_package']
-    __index_url__ = 'https://my.private.index/'
+    __requires__ = ["my_private_package"]
+    __index_url__ = "https://my.private.index/"
 
     import my_private_package
+
     ...
 
 Supplying parameters to Pip

pip-run HEAD $ head -n 6 pyproject.toml | tail -n 2
[tool.black]
skip-string-normalization = true

Is it by design that the configuration for black is different than that for blacken-docs? Is there a way that blacken-docs could be configured to honor the black config?

@asottile
Copy link
Contributor

it probably could manually but wasn't implemented as black doesn't expose their config loading code (and many of black's options are irrelevant or even incorrect for blacken-docs (such as file filtering)) -- a patch would be accepted for the three supported options: -l / -t / -S

@asottile asottile added the enhancement New feature or request label Nov 29, 2020
@asottile asottile closed this as completed Jun 5, 2021
clrpackages pushed a commit to clearlinux-pkgs/keyring that referenced this issue Aug 18, 2021
…23.1.0

Brian Rutledge (1):
      Use shutil for rmtree

Dmitry Shachnev (1):
      Fix markup error in CHANGES.rst

Jason R. Coombs (14):
      Remove automerge. Fixes jaraco/skeleton#49.
      Enable dependabot (#50)
      Replace md file with badge linking to documentation site. Fixes jaraco/skeleton#47.
      Test on Python 3.10
      Remove setup_requires, obviated by build-requires in pyproject.toml.
      Suppress deprecation warnings in flake8 and packaging.tags. Ref pypa/packaging#433.
      Rely on setuptools 56 and drop the explicit mention of the license file in favor of simple discovery.
      Remove workaround for python/typed_ast#156.
      Use line continuations to indicate which exclusions are for which workarounds.
      Remove blacken docs as it cannot honor Python's default repr. Ref adamchainz/blacken-docs#62.
      Add another code
      ⚫ Fade to black.
      👹 Feed the hobgoblins (delint).
      Update changelog.

Spencer Michaels (1):
      Update MacOS keychain APIs.

Sviatoslav Sydorenko (1):
      Make sphinx fail on any warnings (#36)
clrpackages pushed a commit to clearlinux-pkgs/jaraco.collections that referenced this issue Aug 18, 2021
…o version 3.4.0

Brian Rutledge (1):
      Use shutil for rmtree

Jason R. Coombs (11):
      Remove automerge. Fixes jaraco/skeleton#49.
      Enable dependabot (#50)
      Replace md file with badge linking to documentation site. Fixes jaraco/skeleton#47.
      Test on Python 3.10
      Remove setup_requires, obviated by build-requires in pyproject.toml.
      Suppress deprecation warnings in flake8 and packaging.tags. Ref pypa/packaging#433.
      Rely on setuptools 56 and drop the explicit mention of the license file in favor of simple discovery.
      Remove workaround for python/typed_ast#156.
      Use line continuations to indicate which exclusions are for which workarounds.
      Remove blacken docs as it cannot honor Python's default repr. Ref adamchainz/blacken-docs#62.
      Add WeightedLookup

Sviatoslav Sydorenko (1):
      Make sphinx fail on any warnings (#36)
clrpackages pushed a commit to clearlinux-pkgs/importlib_metadata that referenced this issue Aug 18, 2021
…o version 4.6.4

Henry Schreiner (1):
      fix(typing): Path-likes use truediv

Jason R. Coombs (10):
      Rely on setuptools 56 and drop the explicit mention of the license file in favor of simple discovery.
      Remove workaround for python/typed_ast#156.
      Use line continuations to indicate which exclusions are for which workarounds.
      Remove blacken docs as it cannot honor Python's default repr. Ref adamchainz/blacken-docs#62.
      Limit filter to DeprecationWarnings
      Update changelog.
      Add test purported to capture the failure, but it still passes.
      Move the test out of doctest. Still doesn't capture failure.
      Remove unhelpful test.
      Fix attribute name.
clrpackages pushed a commit to clearlinux-pkgs/setuptools that referenced this issue Sep 7, 2021
…on 58.0.0

Alan Fregtman (6):
      Implement "glob:" directive for declarative "data_files" option.
      Add changelog entry for PR #2712.
      Update globbing for [options.data_files] to be implicit, not requiring a custom directive.
      globbing for [options.data_files]: Remove special treatment for filenames with globby characters that exist literally.
      Satisfy some flake8 style checks for the previous commit.
      config.py: Fix line-too-long warning in _parse_list_glob()

Ian Wienand (1):
      build_meta: Clarify the reasons for project requirements in pyproject.toml

Jason R. Coombs (13):
      Trim back chaneglog.
      👹 Feed the hobgoblins (delint).
      Rely on setuptools 56 and drop the explicit mention of the license file in favor of simple discovery.
      Remove workaround for python/typed_ast#156.
      Use line continuations to indicate which exclusions are for which workarounds.
      Remove blacken docs as it cannot honor Python's default repr. Ref asotille/blacken-docs#62.
      Remove blacken docs as it cannot honor Python's default repr. Ref adamchainz/blacken-docs#62.
      Restore whitespace and single quotes after blacken-docs.
      Bump version: 57.4.0 → 57.5.0
      Fix broken Sphinx builds on Python 3.10. Fixes #2763. Ref sphinx-doc/sphinx#9562.
      👹 Feed the hobgoblins (delint).
      Prefer "command" to "function". Use direct imperative voice.
      Bump version: 57.5.0 → 58.0.0

Louis Maddox (1):
      Remove repeated information in same sentence

SeungMin Lee (1):
      Fix broken links in easy_install.py

Thomas Grainger (13):
      run pre-commit in ci
      blacken docs
      disable unused black pre-commit hook
      Delete pre-commit.yml
      add newsfragment
      remove magci trailing commas
      Delete .pre-commit-config.yaml
      readme: update to reflect the cpython distutils status (#48)
      remove 2to3
      add python_requires example
      add python_requires example
      remove lib2to3 usage
      add newsfragment
clrpackages pushed a commit to clearlinux-pkgs/zipp that referenced this issue Sep 30, 2021
Alan Fregtman (1):
      .editorconfig: Set max_line_length to 88 for Python files.

Jason R. Coombs (6):
      Rely on setuptools 56 and drop the explicit mention of the license file in favor of simple discovery.
      Remove workaround for python/typed_ast#156.
      Use line continuations to indicate which exclusions are for which workarounds.
      Remove blacken docs as it cannot honor Python's default repr. Ref adamchainz/blacken-docs#62.
      Add intersphinx mappings for Python to prevent spurious nitpicky failures. Fixes jaraco/skeleton#51.
      Remove news entry unintentionally pulled from CPython. Fixes #77.
clrpackages pushed a commit to clearlinux-pkgs/tempora that referenced this issue Oct 14, 2021
….1.2

Alan Fregtman (1):
      .editorconfig: Set max_line_length to 88 for Python files.

Jason R. Coombs (8):
      Fix doc syntax
      Rely on setuptools 56 and drop the explicit mention of the license file in favor of simple discovery.
      Remove workaround for python/typed_ast#156.
      Use line continuations to indicate which exclusions are for which workarounds.
      Remove blacken docs as it cannot honor Python's default repr. Ref adamchainz/blacken-docs#62.
      Add intersphinx mappings for Python to prevent spurious nitpicky failures. Fixes jaraco/skeleton#51.
      Test on Python 3.10 (final).
      Fix syntax warning in docs. Fixes #18.
clrpackages pushed a commit to clearlinux-pkgs/portend that referenced this issue Oct 14, 2021
….0.0

Alan Fregtman (1):
      .editorconfig: Set max_line_length to 88 for Python files.

Brian Rutledge (1):
      Use shutil for rmtree

Jason R. Coombs (25):
      Exclude dist from discovered packages. Fixes jaraco/skeleton#46.
      It's no longer necessary to filter this warning and it's not a warning anymore.
      Bump minimum pytest
      Require twine 3 with keyring unconditionally required.
      Add comments indicating why the exclusions are present
      Exclude mypy on Python 3.10 as workaround for python/typed_ast#156.
      Bump minimums on pytest-checkdocs and pytest-enabler as found on Setuptools.
      Also deny black on Python 3.10 as workaround for python/typed_ast#156.
      Add leading */ to coverage.run.omit. Workaround for pytest-dev/pytest-cov#456.
      Remove automerge. Fixes jaraco/skeleton#49.
      Enable dependabot (#50)
      Replace md file with badge linking to documentation site. Fixes jaraco/skeleton#47.
      Test on Python 3.10
      Remove setup_requires, obviated by build-requires in pyproject.toml.
      Suppress deprecation warnings in flake8 and packaging.tags. Ref pypa/packaging#433.
      Rely on setuptools 56 and drop the explicit mention of the license file in favor of simple discovery.
      Remove workaround for python/typed_ast#156.
      Use line continuations to indicate which exclusions are for which workarounds.
      Remove blacken docs as it cannot honor Python's default repr. Ref adamchainz/blacken-docs#62.
      Add intersphinx mappings for Python to prevent spurious nitpicky failures. Fixes jaraco/skeleton#51.
      Test on Python 3.10 (final).
      Rely on pytest 6 and drop workaround for pytest-dev/pytest#6178.
      Fix syntax warning in docs.
      Update changelog.
      Remove legacy aliases.

KOLANICH (1):
      Added an .editorconfig. Pull request jaraco/skeleton#43.

Sviatoslav Sydorenko (1):
      Make sphinx fail on any warnings (#36)
clrpackages pushed a commit to clearlinux-pkgs/jaraco.text that referenced this issue Nov 9, 2021
…on 3.6.0

Alan Fregtman (1):
      .editorconfig: Set max_line_length to 88 for Python files.

Jason R. Coombs (10):
      Rely on setuptools 56 and drop the explicit mention of the license file in favor of simple discovery.
      Remove workaround for python/typed_ast#156.
      Use line continuations to indicate which exclusions are for which workarounds.
      Remove blacken docs as it cannot honor Python's default repr. Ref adamchainz/blacken-docs#62.
      Drop Python 2 compatibility in FoldedCase
      Add intersphinx mappings for Python to prevent spurious nitpicky failures. Fixes jaraco/skeleton#51.
      Test on Python 3.10 (final).
      Rely on pytest 6 and drop workaround for pytest-dev/pytest#6178.
      Remove wheel from build requirements. It's implied for wheel builds. Ref pypa/setuptools#1498.
      Rely on importlib.resources traversable API. Fixes DeprecationWarning.
clrpackages pushed a commit to clearlinux-pkgs/jaraco.functools that referenced this issue Nov 9, 2021
…version 3.4.0

Alan Fregtman (1):
      .editorconfig: Set max_line_length to 88 for Python files.

Brian Rutledge (1):
      Use shutil for rmtree

Jason R. Coombs (17):
      Remove automerge. Fixes jaraco/skeleton#49.
      Enable dependabot (#50)
      Replace md file with badge linking to documentation site. Fixes jaraco/skeleton#47.
      Test on Python 3.10
      Remove setup_requires, obviated by build-requires in pyproject.toml.
      Suppress deprecation warnings in flake8 and packaging.tags. Ref pypa/packaging#433.
      Rely on setuptools 56 and drop the explicit mention of the license file in favor of simple discovery.
      Remove workaround for python/typed_ast#156.
      Use line continuations to indicate which exclusions are for which workarounds.
      Rewrite doc for clarity.
      Extend doctest
      Remove blacken docs as it cannot honor Python's default repr. Ref adamchainz/blacken-docs#62.
      Add intersphinx mappings for Python to prevent spurious nitpicky failures. Fixes jaraco/skeleton#51.
      Test on Python 3.10 (final).
      Rely on pytest 6 and drop workaround for pytest-dev/pytest#6178.
      Remove wheel from build requirements. It's implied for wheel builds. Ref pypa/setuptools#1498.
      Use functools.wraps to pass through docstrings in apply.

Sviatoslav Sydorenko (1):
      Make sphinx fail on any warnings (#36)
clrpackages pushed a commit to clearlinux-pkgs/backports.entry_points_selectable that referenced this issue Nov 12, 2021
…version 1.1.0 to version 1.1.1

Alan Fregtman (1):
      .editorconfig: Set max_line_length to 88 for Python files.

Brian Rutledge (1):
      Use shutil for rmtree

Jason R. Coombs (9):
      Rely on setuptools 56 and drop the explicit mention of the license file in favor of simple discovery.
      Remove workaround for python/typed_ast#156.
      Use line continuations to indicate which exclusions are for which workarounds.
      Remove blacken docs as it cannot honor Python's default repr. Ref adamchainz/blacken-docs#62.
      Add intersphinx mappings for Python to prevent spurious nitpicky failures. Fixes jaraco/skeleton#51.
      Test on Python 3.10 (final).
      Rely on pytest 6 and drop workaround for pytest-dev/pytest#6178.
      Remove wheel from build requirements. It's implied for wheel builds. Ref pypa/setuptools#1498.
      Update changelog.
clrpackages pushed a commit to clearlinux-pkgs/pypi-pytest_runner that referenced this issue Mar 1, 2022
…o version 6.0.0

Alan Fregtman (1):
      .editorconfig: Set max_line_length to 88 for Python files.

Anderson Bravalheri (1):
      Ignore flake8/black warnings with pytest 7.0.1 (jaraco/skeleton#58)

Brian Rutledge (1):
      Use shutil for rmtree

Evangelos Foutras (1):
      test_egg_fetcher: use newer setuptools on Python 3.10

Jason R. Coombs (35):
      Rebrand to 'For Enterprise'
      Add a 'For Enterprise' section to the README
      Include token passthrough for azure pipelines publish stage.
      Move Tidelift release note publishing to Github Actions.
      Tidelift no longer requires or expects publishing release notes.
      Remove Tidelift from main.yml, no longer needed
      Test on Python 3.10
      Remove setup_requires, obviated by build-requires in pyproject.toml.
      Suppress deprecation warnings in flake8 and packaging.tags. Ref pypa/packaging#433.
      Rely on setuptools 56 and drop the explicit mention of the license file in favor of simple discovery.
      Remove workaround for python/typed_ast#156.
      Use line continuations to indicate which exclusions are for which workarounds.
      Fix syntax issue in changelog. Fixes #58.
      Implement tidelift banner using a Sphinx directive implemented by jaraco.tidelift.
      Remove blacken docs as it cannot honor Python's default repr. Ref adamchainz/blacken-docs#62.
      Add intersphinx mappings for Python to prevent spurious nitpicky failures. Fixes jaraco/skeleton#51.
      Test on Python 3.10 (final).
      Rely on pytest 6 and drop workaround for pytest-dev/pytest#6178.
      Remove wheel from build requirements. It's implied for wheel builds. Ref pypa/setuptools#1498.
      Require Python 3.7 or later.
      Remove filtered warnings, addressed upstream.
      Update badge year
      Remove setup.py, no longer needed.
      Add exclusions for pytest 7 deprecations in plugins. Fixes jaraco/skeleton#57.
      Use the parent category PytestDeprecationWarning, which is available on older pytest versions. Fixes jaraco/skeleton#57.
      Bump pytest-mypy and remove workaround for realpython/pytest-mypy#131.
      Require jaraco.packaging 9 adding compatibility for projects with no setup.py file.
      Ran pre-commit autoupdate
      🧎‍♀️ Genuflect to the types.
      Update test to install pytest-runner using pip.
      Tests no longer run on Python 3.6
      Update changelog.
      Remove legacy code
      ⚫ Fade to black.
      Move module to package for simplicity of packaging.
clrpackages pushed a commit to clearlinux-pkgs/pypi-jaraco.classes that referenced this issue Jul 14, 2022
…to version 3.2.2

Alan Fregtman (1):
      .editorconfig: Set max_line_length to 88 for Python files.

Anderson Bravalheri (2):
      Ignore flake8/black warnings with pytest 7.0.1 (jaraco/skeleton#58)
      Update Github actions to v3 (#62)

Brian Rutledge (1):
      Use shutil for rmtree

Hugo van Kemenade (1):
      Update base URL for PEPs (#61)

Jason R. Coombs (52):
      Add Tidelift template
      Rely on alabaster theme to support sidebar rendering.
      Use nicer, simpler phrasing
      Add support for automatic publishing of release notes
      Use technique for environment passing matching that found in jaraco/skeleton
      Move Tidelift token into Travis configuration
      Update badge URL
      Add funding reference to project
      List sidebars to avoid errors looking for template 't'
      Rebrand to 'For Enterprise'
      Add a 'For Enterprise' section to the README
      Include token passthrough for azure pipelines publish stage.
      Move Tidelift release note publishing to Github Actions.
      It's no longer necessary to filter this warning and it's not a warning anymore.
      Bump minimum pytest
      Require twine 3 with keyring unconditionally required.
      Add comments indicating why the exclusions are present
      Exclude mypy on Python 3.10 as workaround for python/typed_ast#156.
      Bump minimums on pytest-checkdocs and pytest-enabler as found on Setuptools.
      Also deny black on Python 3.10 as workaround for python/typed_ast#156.
      Add leading */ to coverage.run.omit. Workaround for pytest-dev/pytest-cov#456.
      Tidelift no longer requires or expects publishing release notes.
      Remove Tidelift from main.yml, no longer needed
      Remove automerge. Fixes jaraco/skeleton#49.
      Enable dependabot (#50)
      Replace md file with badge linking to documentation site. Fixes jaraco/skeleton#47.
      Test on Python 3.10
      Remove setup_requires, obviated by build-requires in pyproject.toml.
      Suppress deprecation warnings in flake8 and packaging.tags. Ref pypa/packaging#433.
      Rely on setuptools 56 and drop the explicit mention of the license file in favor of simple discovery.
      Remove workaround for python/typed_ast#156.
      Use line continuations to indicate which exclusions are for which workarounds.
      Implement tidelift banner using a Sphinx directive implemented by jaraco.tidelift.
      Remove blacken docs as it cannot honor Python's default repr. Ref adamchainz/blacken-docs#62.
      Add intersphinx mappings for Python to prevent spurious nitpicky failures. Fixes jaraco/skeleton#51.
      Test on Python 3.10 (final).
      Rely on pytest 6 and drop workaround for pytest-dev/pytest#6178.
      Remove wheel from build requirements. It's implied for wheel builds. Ref pypa/setuptools#1498.
      Require Python 3.7 or later.
      Remove filtered warnings, addressed upstream.
      Update badge year
      Remove setup.py, no longer needed.
      Add exclusions for pytest 7 deprecations in plugins. Fixes jaraco/skeleton#57.
      Use the parent category PytestDeprecationWarning, which is available on older pytest versions. Fixes jaraco/skeleton#57.
      Bump pytest-mypy and remove workaround for realpython/pytest-mypy#131.
      Require jaraco.packaging 9 adding compatibility for projects with no setup.py file.
      Ran pre-commit autoupdate
      Add Python 3.11 into the matrix using workaround from actions/setup-python#213. Drop 3.9 from matrix for efficiency.
      Prefer spaces for rst. Fixes jaraco/skeleton#64.
      Honor PEP 518 with pytest-enabler.
      Ran pre-commit autoupdate
      Update changelog.

KOLANICH (1):
      Added an .editorconfig. Pull request jaraco/skeleton#43.

Sviatoslav Sydorenko (2):
      Make sphinx fail on any warnings (#36)
      Inject check job into CI workflow as ultimate flag (#55)

wim glenn (1):
      exclude build env from cov reporting (#60)
@real-yfprojects
Copy link

real-yfprojects commented Aug 15, 2022

Instead of calling black through python this tool could call black through subprocess.Popen and pass the string to format through stdin. This allows leveraging all black configuration features with low effort of maintaining since this approach uses the official interface.

I can prepare a PR for that if this change is wanted.

@asottile
Copy link
Contributor

it is not wanted, that would be extremely slow

@real-yfprojects
Copy link

it is not wanted, that would be extremely slow

While keeping multiple configuration files in sync is extremly error prone.

Repository owner locked as resolved and limited conversation to collaborators Aug 15, 2022
@asottile
Copy link
Contributor

feel free to fork the software if you want to maintain such a thing. I cannot accept that trade off and it will not work correctly in all cases given what I said in the comment directly above yours

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants