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

Move Black to pre-commit #503

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ repos:
name: "Python: imports"
args: ["--py39-plus"]

- repo: "https://github.com/psf/black-pre-commit-mirror"
rev: "24.10.0"
hooks:
- id: "black"
name: "Python: format"
args: ["--target-version", "py39", "--line-length", "120"]

- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: "v5.0.0"
hooks:
Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ max-line-length = 120
#
# https://www.flake8rules.com/rules/W503.html
# https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator
ignore = W503
#
# E203 and E701 are Black-specific exclusions.
ignore = E203,E701,W503

[mypy]
check_untyped_defs = true
Expand Down
33 changes: 18 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,30 @@
readme = f.read()

kerberos_require = ["requests_kerberos"]
gssapi_require = [""
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure about the purpose of "" here. Perhaps it should be removed?

"requests_gssapi",
# PyPy compatibility issue https://github.com/jborean93/pykrb5/issues/49
"krb5 == 0.5.1"]
gssapi_require = [
"" "requests_gssapi",
# PyPy compatibility issue https://github.com/jborean93/pykrb5/issues/49
"krb5 == 0.5.1",
]
sqlalchemy_require = ["sqlalchemy >= 1.3"]
external_authentication_token_cache_require = ["keyring"]

# We don't add localstorage_require to all_require as users must explicitly opt in to use keyring.
all_require = kerberos_require + sqlalchemy_require

tests_require = all_require + gssapi_require + [
# httpretty >= 1.1 duplicates requests in `httpretty.latest_requests`
# https://github.com/gabrielfalcao/HTTPretty/issues/425
"httpretty < 1.1",
"pytest",
"pytest-runner",
"pre-commit",
"black",
"isort",
Copy link
Member Author

Choose a reason for hiding this comment

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

Both isort and black are here but were never enforced. Neither were mentioned in the development documentation as well.

Copy link
Member

Choose a reason for hiding this comment

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

might want to look at #227 for context.

The TL;DR version was:

  • While standard code format is nice black often makes changes to the detriment of readability
  • If we ever do this we need to figure out a way to be history preserving (probably via blame-ignore config - jvanzyl/provisio@a4cdb8d)
  • black and isort running in pre-commit makes iteration slower sometimes since you are prevented from committing or running ci just because of style issues

"keyring"
]
tests_require = (
all_require
+ gssapi_require
+ [
# httpretty >= 1.1 duplicates requests in `httpretty.latest_requests`
# https://github.com/gabrielfalcao/HTTPretty/issues/425
"httpretty < 1.1",
"pytest",
"pytest-runner",
"pre-commit",
"keyring",
]
)

setup(
name=about["__title__"],
Expand Down
12 changes: 2 additions & 10 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,7 @@ def start_trino(image_tag=None):


def wait_for_trino_workers(host, port, timeout=180):
request = TrinoRequest(
host=host,
port=port,
client_session=ClientSession(
user="test_fixture"
)
)
request = TrinoRequest(host=host, port=port, client_session=ClientSession(user="test_fixture"))
sql = "SELECT state FROM system.runtime.nodes"
t0 = time.time()
while True:
Expand Down Expand Up @@ -124,9 +118,7 @@ def start_trino_and_wait(image_tag=None):
if host:
port = os.environ.get("TRINO_RUNNING_PORT", DEFAULT_PORT)
else:
container_id, proc, host, port = start_local_trino_server(
image_tag
)
container_id, proc, host, port = start_local_trino_server(image_tag)

print("trino.server.hostname {}".format(host))
print("trino.server.port {}".format(port))
Expand Down
Loading
Loading