Skip to content

Commit 88c31e3

Browse files
SG-43835 Fix black pre-commit/CI discrepancy by removing exclude (#1111)
* SG-43835 Fix black pre-commit/CI discrepancy by removing exclude Remove the `exclude: "tests|python/tank"` override from the black hook in `.pre-commit-config.yaml` so that local pre-commit runs black on the same set of files as the CI pipeline. Apply black formatting to the previously-excluded files to bring them into compliance. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * SG-43835 Apply black 26.5.1 formatting to remaining files Re-run black at the correct pinned version (26.5.1) to catch files missed by the initial formatting pass which used an older version. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * SG-43835 Disable black in hound - already enforced by pre-commit CI Hound runs its own black version which differs from the one pinned in .pre-commit-config.yaml, causing spurious review comments. Black formatting is already enforced by the CI pipeline via pre-commit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * SG-43835 Fix black formatting in flowam/open.py Remove extra blank line before logger assignment flagged by CI's code-style-validation job. --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 627b08b commit 88c31e3

117 files changed

Lines changed: 1248 additions & 927 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.hound.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ python:
1414
enabled: true
1515
config_file: .flake8
1616

17+
black:
18+
enabled: false
19+
1720
rubocop:
1821
enabled: false

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,3 @@ repos:
5757
rev: 26.5.1
5858
hooks:
5959
- id: black
60-
exclude: "tests|python\/tank"

python/tank/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,6 @@ def __fix_tank_vendor():
171171

172172
# expose the support url
173173
from .constants import (
174-
DEFAULT_STORAGE_ROOT_HOOK_NAME,
175-
SUPPORT_URL as support_url,
174+
DEFAULT_STORAGE_ROOT_HOOK_NAME,
175+
SUPPORT_URL as support_url,
176176
)

python/tank/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Sgtk(object):
3838
manipulation and the Toolkit template system.
3939
"""
4040

41-
(DEFAULT, CENTRALIZED, DISTRIBUTED) = range(3)
41+
DEFAULT, CENTRALIZED, DISTRIBUTED = range(3)
4242

4343
def __init__(self, project_path):
4444
"""

python/tank/authentication/app_session_launcher.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def process(
8989

9090
url_handlers.append(
9191
urllib.request.HTTPSHandler(
92-
context = ssl.create_default_context(
92+
context=ssl.create_default_context(
9393
cafile=ca_certs,
9494
),
9595
),
@@ -255,10 +255,12 @@ def process(
255255
elif response_code_major == 3:
256256
location = response.headers.get("location", None)
257257

258-
logger.debug("Request redirected: http code: {code}; redirect to: {location}".format(
259-
code=response.code,
260-
location=location,
261-
))
258+
logger.debug(
259+
"Request redirected: http code: {code}; redirect to: {location}".format(
260+
code=response.code,
261+
location=location,
262+
)
263+
)
262264

263265
raise AuthenticationError(
264266
"Request redirected",
@@ -286,9 +288,11 @@ def process(
286288
)
287289

288290
elif response.code != http.client.OK:
289-
logger.debug("Request denied: http code is: {code}".format(
290-
code=response.code,
291-
))
291+
logger.debug(
292+
"Request denied: http code is: {code}".format(
293+
code=response.code,
294+
)
295+
)
292296
raise AuthenticationError(
293297
"Request denied",
294298
payload=getattr(response, "json", response),
@@ -503,9 +507,11 @@ def build_user_agent():
503507

504508
lh = logging.StreamHandler()
505509
lh.setLevel(logging.DEBUG)
506-
lh.setFormatter(logging.Formatter(
507-
"%(asctime)s - %(levelname)s - %(message)s",
508-
))
510+
lh.setFormatter(
511+
logging.Formatter(
512+
"%(asctime)s - %(levelname)s - %(message)s",
513+
)
514+
)
509515

510516
logger.addHandler(lh)
511517
print()

python/tank/authentication/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
def method_resolve_reverse(m):
2323
global method_resolve
2424

25-
for (k, v) in method_resolve.items():
25+
for k, v in method_resolve.items():
2626
if v == m:
2727
return k

python/tank/authentication/errors.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ def __init__(self, login):
7373
"""
7474
:param str login: ``login`` field value of the ``HumanUser`` that could not be resolved.
7575
"""
76-
super().__init__(
77-
"person", "HumanUser", "login", login
78-
)
76+
super().__init__("person", "HumanUser", "login", login)
7977

8078

8179
class UnresolvableScriptUser(UnresolvableUser):
@@ -87,9 +85,7 @@ def __init__(self, script_name):
8785
"""
8886
:param str script_name: ``firstname`` field value of the ``ApiUser`` that could not be resolved.
8987
"""
90-
super().__init__(
91-
"script", "ApiUser", "firstname", script_name
92-
)
88+
super().__init__("script", "ApiUser", "firstname", script_name)
9389

9490

9591
class ConsoleLoginNotSupportedError(ShotgunAuthenticationError):

python/tank/authentication/interactive_authentication.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import os
3434
from tank.util import is_windows
3535

36-
3736
logger = LogManager.get_logger(__name__)
3837

3938

@@ -78,6 +77,7 @@ def _get_ui_state() -> bool:
7877

7978
return bool(QtGui and QtGui.QApplication.instance())
8079

80+
8181
class SessionRenewal(object):
8282
"""
8383
Handles multi-threaded session renewal. This class handles the use case when
@@ -220,6 +220,7 @@ def renew_session(user):
220220
# If we have a gui, we need gui based authentication
221221
if has_ui:
222222
from .ui_authentication import UiAuthenticationHandler
223+
223224
authenticator = UiAuthenticationHandler(
224225
is_session_renewal=True, session_metadata=user.get_session_metadata()
225226
)

python/tank/authentication/login_dialog.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
at any point.
1818
--------------------------------------------------------------------------------
1919
"""
20+
2021
import os
2122
import sys
2223
from tank_vendor import shotgun_api3
@@ -109,6 +110,7 @@ def run(self):
109110
"""
110111
self._site_info.reload(self._url_to_test, self._http_proxy)
111112

113+
112114
class LoginDialog(QtGui.QDialog):
113115
"""
114116
Dialog for getting user credentials.
@@ -494,15 +496,21 @@ def _toggle_web(self, method_selected=None):
494496
# - they need to use the legacy login / passphrase to use a PAT with
495497
# Autodesk Identity authentication
496498
if os.environ.get("SGTK_FORCE_STANDARD_LOGIN_DIALOG"):
497-
logger.info("Using the standard login dialog with the Flow Production Tracking")
499+
logger.info(
500+
"Using the standard login dialog with the Flow Production Tracking"
501+
)
498502
else:
499503
if _is_running_in_desktop():
500-
can_use_web = can_use_web or self.site_info.autodesk_identity_enabled
504+
can_use_web = (
505+
can_use_web or self.site_info.autodesk_identity_enabled
506+
)
501507

502508
# If we have full support for Web-based login, or if we enable it in our
503509
# environment, use the Unified Login Flow for all authentication modes.
504510
if get_shotgun_authenticator_support_web_login():
505-
can_use_web = can_use_web or self.site_info.unified_login_flow_enabled
511+
can_use_web = (
512+
can_use_web or self.site_info.unified_login_flow_enabled
513+
)
506514

507515
if method_selected:
508516
# Selecting requested mode (credentials, qt_web_login or app_session_launcher)
@@ -514,9 +522,7 @@ def _toggle_web(self, method_selected=None):
514522
method_selected = session_cache.get_preferred_method(site)
515523

516524
# Make sure that the method_selected is currently supported
517-
if (
518-
method_selected == auth_constants.METHOD_WEB_LOGIN and not can_use_web
519-
) or (
525+
if (method_selected == auth_constants.METHOD_WEB_LOGIN and not can_use_web) or (
520526
method_selected == auth_constants.METHOD_ASL and not can_use_asl
521527
):
522528
method_selected = None
@@ -528,9 +534,7 @@ def _toggle_web(self, method_selected=None):
528534
)
529535

530536
# Make sure that the method_selected is currently supported
531-
if (
532-
method_selected == auth_constants.METHOD_WEB_LOGIN and not can_use_web
533-
) or (
537+
if (method_selected == auth_constants.METHOD_WEB_LOGIN and not can_use_web) or (
534538
method_selected == auth_constants.METHOD_ASL and not can_use_asl
535539
):
536540
method_selected = None
@@ -701,7 +705,9 @@ def result(self):
701705
"Logged In",
702706
properties={
703707
"authentication_method": self.site_info.user_authentication_method,
704-
"authentication_experience": auth_constants.method_resolve.get(self.method_selected),
708+
"authentication_experience": auth_constants.method_resolve.get(
709+
self.method_selected
710+
),
705711
"authentication_interface": "qt_dialog",
706712
"authentication_renewal": self._is_session_renewal,
707713
},
@@ -770,7 +776,10 @@ def _ok_pressed(self):
770776

771777
# Cleanup the URL and update the GUI.
772778
if self.method_selected != auth_constants.METHOD_BASIC:
773-
if site.startswith("http://") and "SGTK_AUTH_ALLOW_NO_HTTPS" not in os.environ:
779+
if (
780+
site.startswith("http://")
781+
and "SGTK_AUTH_ALLOW_NO_HTTPS" not in os.environ
782+
):
774783
site = "https" + site[4:]
775784
self.ui.site.setEditText(site)
776785

python/tank/authentication/session_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def _try_load_site_authentication_file(file_path):
222222
content.setdefault(_RECENT_USERS, [])
223223

224224
if content.get(_PREFERRED_METHOD, "not null") is None:
225-
del(content[_PREFERRED_METHOD])
225+
del content[_PREFERRED_METHOD]
226226

227227
for user in content[_USERS]:
228228
user[_LOGIN] = user[_LOGIN].strip()

0 commit comments

Comments
 (0)