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

[IMP] cfg: update black version #129

Merged
merged 2 commits into from
Jan 22, 2024
Merged

Conversation

antonag32
Copy link
Contributor

Autofix hooks have been updated to their latest version. Biggest change involves black removing whitespaces after class/method declarations.

BREAKING CHANGE: black may generate diffs on projects

@antonag32 antonag32 changed the title [IMP] cfg: update autofix hook versions [IMP] cfg: update black version Nov 27, 2023
@antonag32 antonag32 force-pushed the black-update branch 6 times, most recently from 14f7767 to 46032b4 Compare January 3, 2024 02:59
@antonag32
Copy link
Contributor Author

It seems like there is a problem with tmpdir generation on windows. It generates them under a different user. This stack overflow seems related:

https://stackoverflow.com/questions/51129686/gettemppatha-returning-incorrect-user-folder

@antonag32
Copy link
Contributor Author

This hack confirms it:

diff --git a/tests/test_pre_commit_vauxoo.py b/tests/test_pre_commit_vauxoo.py
index e284313..060d1b2 100644
--- a/tests/test_pre_commit_vauxoo.py
+++ b/tests/test_pre_commit_vauxoo.py
@@ -2,6 +2,7 @@ from __future__ import annotations
 
 import logging
 import os
+import platform
 import posixpath
 import re
 import shutil
@@ -27,6 +28,11 @@ class TestPreCommitVauxoo(unittest.TestCase):
         self.old_environ = os.environ.copy()
         self.original_work_dir = os.getcwd()
         self.tmp_dir = tempfile.mkdtemp(suffix="_pre_commit_vauxoo")
+        if platform.system() == "Windows":
+            print("TMP DIR BEFORE HACK %s" % self.tmp_dir)
+            self.tmp_dir = self.tmp_dir.replace("RUNNER~1", "runneradmin")
+            print("TMP DIR AFTER HACK %s" % self.tmp_dir)
+
         os.chdir(self.tmp_dir)
         self.runner = CliRunner()
         src_path = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "resources")

@antonag32 antonag32 marked this pull request as draft January 3, 2024 03:36
@antonag32
Copy link
Contributor Author

Marked as draft until non-hacky fix is found.

@antonag32 antonag32 force-pushed the black-update branch 2 times, most recently from 076f076 to 8f9f4ec Compare January 3, 2024 14:48
@antonag32 antonag32 marked this pull request as ready for review January 3, 2024 14:57
@antonag32 antonag32 requested review from moylop260 and luisg123v and removed request for moylop260 January 17, 2024 20:19
@@ -26,7 +26,7 @@ def setUp(self):
super().setUp()
self.old_environ = os.environ.copy()
self.original_work_dir = os.getcwd()
self.tmp_dir = tempfile.mkdtemp(suffix="_pre_commit_vauxoo")
self.tmp_dir = os.path.realpath(tempfile.mkdtemp(suffix="_pre_commit_vauxoo"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you perform this on a separate commit, please?

Because it's not strictly related and to explain in commit message why it's necessary.

Black has been updated to its latest version. Biggest
change involves black removing whitespaces after class/method
declarations.

BREAKING CHANGE: black may generate diffs on projects
Tests were updated to prevent edge cases where mkdtemp() returns "short"
DOS paths on Windows, which cause errors like the following:

File "src\black\__init__.py", line 616, in main
  File "src\black\__init__.py", line 703, in get_sources
  File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\pathlib.py", line 908, in relative_to
    raise ValueError("{!r} does not start with {!r}"
ValueError: 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmpc6klofvk_pre_commit_vauxoo\\module_autofix1\\__init__.py'
does not start with 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\tmpc6klofvk_pre_commit_vauxoo
@moylop260 moylop260 merged commit 0230ac2 into Vauxoo:main Jan 22, 2024
16 checks passed
@moylop260 moylop260 deleted the black-update branch January 22, 2024 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants