Skip to content

Commit

Permalink
feat: Format code with ruff and check JS with prettier (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
marksweb authored Feb 2, 2024
1 parent 06eb8f6 commit 4916604
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 33 deletions.
28 changes: 17 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ci:
autofix_commit_msg: |
ci: auto fixes from pre-commit hooks
autofix_commit_msg: |
ci: auto fixes from pre-commit hooks
for more information, see https://pre-commit.ci
autofix_prs: false
autoupdate_commit_msg: 'ci: pre-commit autoupdate'
autoupdate_schedule: monthly
for more information, see https://pre-commit.ci
autofix_prs: false
autoupdate_commit_msg: "ci: pre-commit autoupdate"
autoupdate_schedule: monthly

default_language_version:
python: python3.12
Expand All @@ -18,7 +18,7 @@ repos:
args: ["--py38-plus"]

- repo: https://github.com/adamchainz/django-upgrade
rev: '1.15.0'
rev: "1.15.0"
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]
Expand All @@ -39,6 +39,7 @@ repos:
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/remastr/pre-commit-django-check-migrations
rev: v0.1.0
Expand All @@ -50,7 +51,12 @@ repos:
- repo: https://github.com/rstcheck/rstcheck
rev: v6.2.0
hooks:
- id: rstcheck
additional_dependencies:
- sphinx==6.1.3
- tomli==2.0.1
- id: rstcheck
additional_dependencies:
- sphinx==6.1.3
- tomli==2.0.1

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0
hooks:
- id: prettier
24 changes: 12 additions & 12 deletions docs/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ Snapshots

.. code-block:: python
'explorer.tasks.snapshot_queries': {
'task': 'explorer.tasks.snapshot_queries',
'schedule': crontab(hour=1, minute=0)
}
app.conf.beat_schedule = {
'explorer.tasks.snapshot_queries': {
'task': 'explorer.tasks.snapshot_queries',
'schedule': crontab(hour=1, minute=0)
}
}
- Requires celery, obviously. Also uses boto3. All
of these deps are optional and can be installed with
Expand Down Expand Up @@ -94,8 +96,6 @@ Schema Helper
set ``EXPLORER_ENABLE_TASKS`` and ``EXPLORER_ASYNC_SCHEMA`` to
``True``.

.. _Template Columns:

Template Columns
----------------
- Let's say you have a query like ``SELECT id, email FROM user`` and
Expand Down Expand Up @@ -162,10 +162,12 @@ Query Logs

.. code-block:: python
'explorer.tasks.truncate_querylogs': {
'task': 'explorer.tasks.truncate_querylogs',
'schedule': crontab(hour=1, minute=0),
'kwargs': {'days': 30}
app.conf.beat_schedule = {
'explorer.tasks.truncate_querylogs': {
'task': 'explorer.tasks.truncate_querylogs',
'schedule': crontab(hour=1, minute=0),
'kwargs': {'days': 30}
}
}
Multiple Connections
Expand All @@ -179,8 +181,6 @@ Multiple Connections
way. See connections.py for more documentation on
multi-connection setup.

.. _Power tips:

Power tips
----------
- On the query listing page, focus gets set to a search box so you
Expand Down
2 changes: 1 addition & 1 deletion docs/history.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.. include:: ../HISTORY.rst
.. include:: ../HISTORY.rst
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.. rstcheck: ignore-next-code-block
.. Django SQL Explorer documentation master file, created by
sphinx-quickstart on Thu Oct 15 17:39:19 2020.
You can adapt this file completely to your liking, but it should at least
Expand Down
12 changes: 4 additions & 8 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ If you would also like to support downloading Excel files install with the depen
Add to your ``INSTALLED_APPS``, located in the ``settings.py`` file in your project folder:

.. code-block:: python
:emphasize-lines: 3
.. code-block:: python
:emphasize-lines: 3
INSTALLED_APPS = (
...,
'explorer',
...
)
Configure your settings to something like:
Expand All @@ -54,15 +52,13 @@ Add the following to your urls.py (all Explorer URLs are restricted
via the ``EXPLORER_PERMISSION_VIEW`` and ``EXPLORER_PERMISSION_CHANGE``
settings. See Settings section below for further documentation.):

.. code-block:: python
:emphasize-lines: 5
.. code-block:: python
:emphasize-lines: 5
from django.urls import path, include
urlpatterns = [
...
path('explorer/', include('explorer.urls')),
...
]
If you want to quickly use django-sql-explorer with the existing default
Expand Down
2 changes: 1 addition & 1 deletion docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ A dict granting view permissions on specific queries of the form

.. code-block:: python
EXPLORER_GET_USER_QUERY_VIEWS = {userId:[queryId, ...], ...}
EXPLORER_GET_USER_QUERY_VIEWS = {userId: [queryId, ], }
**Default Value:**

Expand Down
7 changes: 7 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ combine-as-imports = true
known-first-party = [
"explorer",
]
extra-standard-library = ["dataclasses"]

[lint.pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
keep-runtime-typing = true

[format]
quote-style = "double"
indent-style = "space"
docstring-code-format = true
docstring-code-line-length = 80

0 comments on commit 4916604

Please sign in to comment.