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

[pre-commit.ci] pre-commit autoupdate #4547

Merged
merged 3 commits into from
Jan 7, 2025
Merged

Conversation

pre-commit-ci[bot]
Copy link
Contributor

@pre-commit-ci pre-commit-ci bot commented Jan 7, 2025

updates:
- [github.com/pre-commit/mirrors-mypy: v1.13.0 → v1.14.1](pre-commit/mirrors-mypy@v1.13.0...v1.14.1)
@MeGaGiGaGon
Copy link
Contributor

I did a bit of digging, and the mypy failure is ultimately from this typeshed pr: python/typeshed#12884. At that time pytest was the only one to get noticed by mypy-primer, with the same issue black is having now. Going off the fix in pytest, the mypy failure can be fixed by

PS C:\...\black> git diff --cached
diff --git a/tests/test_black.py b/tests/test_black.py
index 84061f1..e737f28 100644
--- a/tests/test_black.py
+++ b/tests/test_black.py
@@ -1355,8 +1355,10 @@ def test_reformat_one_with_stdin_empty(self) -> None:

         def _new_wrapper(
             output: io.StringIO, io_TextIOWrapper: type[io.TextIOWrapper]
-        ) -> Callable[[Any, Any], io.TextIOWrapper]:
-            def get_output(*args: Any, **kwargs: Any) -> io.TextIOWrapper:
+        ) -> Callable[[Any, Any], Union[io.TextIOWrapper, io.StringIO]]:
+            def get_output(
+                *args: Any, **kwargs: Any
+            ) -> Union[io.TextIOWrapper, io.StringIO]:
                 if args == (sys.stdout.buffer,):
                     # It's `format_stdin_to_stdout()`
        def _new_wrapper(
            output: io.StringIO, io_TextIOWrapper: type[io.TextIOWrapper]
        ) -> Callable[[Any, Any], Union[io.TextIOWrapper, io.StringIO]]:
            def get_output(
                *args: Any, **kwargs: Any
            ) -> Union[io.TextIOWrapper, io.StringIO]:

But because github I can't find a good way to get these changes into this PR. As far as I can tell the only options are leaving a comment, or opening a PR against pre-commit-ci-update-config, neither of which are great.

@cooperlees
Copy link
Collaborator

Ahhh - I tried locally but didn't Union both the inner and outer ... I'll checkout the branch later and push a commit ... thanks!

@cooperlees cooperlees added the skip news Pull requests that don't need a changelog entry. label Jan 7, 2025
@cooperlees
Copy link
Collaborator

Wat have I screwed up?

cooper@cooper-fedora-MJ0J8MTZ:~/repos/black$ /tmp/tb/bin/pip install -e .
Obtaining file:///home/cooper/repos/black
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Installing backend dependencies ... done
  Preparing editable metadata (pyproject.toml) ... done
Collecting click>=8.0.0 (from black==24.10.1.dev28+ge157ba4)
  Using cached click-8.1.8-py3-none-any.whl.metadata (2.3 kB)
Collecting mypy-extensions>=0.4.3 (from black==24.10.1.dev28+ge157ba4)
  Using cached mypy_extensions-1.0.0-py3-none-any.whl.metadata (1.1 kB)
Collecting packaging>=22.0 (from black==24.10.1.dev28+ge157ba4)
  Using cached packaging-24.2-py3-none-any.whl.metadata (3.2 kB)
Collecting pathspec>=0.9.0 (from black==24.10.1.dev28+ge157ba4)
  Using cached pathspec-0.12.1-py3-none-any.whl.metadata (21 kB)
Requirement already satisfied: platformdirs>=2 in /tmp/tb/lib64/python3.12/site-packages (from black==24.10.1.dev28+ge157ba4) (4.3.6)
Using cached click-8.1.8-py3-none-any.whl (98 kB)
Using cached mypy_extensions-1.0.0-py3-none-any.whl (4.7 kB)
Using cached packaging-24.2-py3-none-any.whl (65 kB)
Using cached pathspec-0.12.1-py3-none-any.whl (31 kB)
Building wheels for collected packages: black
  Building editable for black (pyproject.toml) ... done
  Created wheel for black: filename=black-24.10.1.dev28+ge157ba4-py3-none-any.whl size=32946 sha256=600b6942a86cf8beba82d2b915731fe93272de5347b0c2790765544d841198cd
  Stored in directory: /tmp/pip-ephem-wheel-cache-rzzvnudn/wheels/00/95/9d/c4d5162ad7d2afb9a86127858f7e288de756e1564bffb5ab62
Successfully built black
Installing collected packages: pathspec, packaging, mypy-extensions, click, black
Successfully installed black-24.10.1.dev28+ge157ba4 click-8.1.8 mypy-extensions-1.0.0 packaging-24.2 pathspec-0.12.1
cooper@cooper-fedora-MJ0J8MTZ:~/repos/black$ /tmp/tb/bin/black src/ tests/ docs/ scripts/
All done! ✨ 🍰 ✨
64 files left unchanged.

@MeGaGiGaGon
Copy link
Contributor

The formatting got messed up

        ) -> Callable[[Any, Any], Union[io.StringIO, io.TextIOWrapper]]:
            def get_output(
                *args: Any,
                **kwargs: Any
            ) -> Union[io.StringIO, io.TextIOWrapper]:

vs

        ) -> Callable[[Any, Any], Union[io.TextIOWrapper, io.StringIO]]:
            def get_output(
                *args: Any, **kwargs: Any
            ) -> Union[io.TextIOWrapper, io.StringIO]:

@MeGaGiGaGon
Copy link
Contributor

MeGaGiGaGon commented Jan 7, 2025

I'm still not sure how exactly the auto-format fix might work, I'm not good enough with CI, so I always manually run black on the segment of the file in question to make sure it formats correctly :)
playground I used

@cooperlees
Copy link
Collaborator

I did run black and it didn't change the formatting, there must be options or config somewhere in CI is all I can think of ...

@cooperlees cooperlees merged commit 40b73f2 into main Jan 7, 2025
42 checks passed
@cooperlees cooperlees deleted the pre-commit-ci-update-config branch January 7, 2025 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news Pull requests that don't need a changelog entry.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants