Skip to content

Commit

Permalink
chore: update linters (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv authored Apr 25, 2024
1 parent ce3aeb7 commit 0f91f08
Show file tree
Hide file tree
Showing 102 changed files with 1,244 additions and 1,267 deletions.
37 changes: 9 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
exclude: (quetz/migrations)
repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.1
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-use-fstring
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
# Note: updating to v1.0.0 a bit more work
rev: v0.902
rev: v0.991
hooks:
- id: mypy
files: ^quetz/
Expand All @@ -33,17 +27,4 @@ repos:
- types-toml
- types-ujson
- types-aiofiles
args: [--show-error-codes]
- repo: https://github.com/Quantco/pre-commit-mirrors-prettier
rev: 2.7.1
hooks:
- id: prettier-conda
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.314
hooks:
- id: pyright
- repo: https://github.com/Quantco/pre-commit-mirrors-typos
rev: 1.16.26
hooks:
- id: typos-conda
exclude: (quetz/tests/authentification/test_oauth.py)
args: [--show-error-codes, --implicit-optional]
14 changes: 7 additions & 7 deletions docker/jupyterhub_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
## Set the log level by value or name.
# Choices: any of [0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL']
# Default: 30
c.Application.log_level = 'DEBUG'
c.Application.log_level = "DEBUG"

## Instead of starting the Application, dump configuration to stdout
# Default: False
Expand Down Expand Up @@ -454,7 +454,7 @@

## Set the log level by value or name.
# See also: Application.log_level
c.JupyterHub.log_level = 'DEBUG'
c.JupyterHub.log_level = "DEBUG"

## Specify path to a logo image to override the Jupyter logo in the banner.
# Default: ''
Expand Down Expand Up @@ -568,13 +568,13 @@

c.JupyterHub.services = [
{
'name': 'quetz',
'url': 'http://web:8000',
"name": "quetz",
"url": "http://web:8000",
# any secret >8 characters, you'll use api_token to
# authenticate api requests to the hub from your service
'oauth_client_id': 'quetz_client',
'oauth_redirect_uri': 'http://localhost:8000/auth/jupyterhub/authorize',
'api_token': 'super-secret',
"oauth_client_id": "quetz_client",
"oauth_redirect_uri": "http://localhost:8000/auth/jupyterhub/authorize",
"api_token": "super-secret",
}
]

Expand Down
18 changes: 9 additions & 9 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@
import os
import sys

sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath("../.."))


# -- Project information -----------------------------------------------------

project = 'Quetz'
copyright = '2020, QuantStack'
author = 'QuantStack'
project = "Quetz"
copyright = "2020, QuantStack"
author = "QuantStack"

# The full version, including alpha/beta/rc tags
release = '0.1'
release = "0.1"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc']
extensions = ["sphinx.ext.autodoc"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -47,12 +47,12 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_book_theme'
html_theme = "sphinx_book_theme"
html_logo = "_static/quetz_logo.png"
html_title = "documentation"
html_favicon = "_static/quetz_favicon.ico"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
30 changes: 15 additions & 15 deletions init_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ def init_test_db():
testUsers = []

try:
for index, username in enumerate(['alice', 'bob', 'carol', 'dave']):
for index, username in enumerate(["alice", "bob", "carol", "dave"]):
user = User(id=uuid.uuid4().bytes, username=username)

identity = Identity(
provider='dummy',
provider="dummy",
identity_id=str(index),
username=username,
)

profile = Profile(name=username.capitalize(), avatar_url='/avatar.jpg')
profile = Profile(name=username.capitalize(), avatar_url="/avatar.jpg")

user.identities.append(identity)
user.profile = profile
Expand All @@ -44,51 +44,51 @@ def init_test_db():

for channel_index in range(30):
channel = Channel(
name=f'channel{channel_index}',
description=f'Description of channel{channel_index}',
name=f"channel{channel_index}",
description=f"Description of channel{channel_index}",
private=False,
)

for package_index in range(random.randint(5, 100)):
package = Package(
name=f'package{package_index}',
description=f'Description of package{package_index}',
name=f"package{package_index}",
description=f"Description of package{package_index}",
)
channel.packages.append(package)

test_user = testUsers[random.randint(0, len(testUsers) - 1)]
package_member = PackageMember(
package=package, channel=channel, user=test_user, role='owner'
package=package, channel=channel, user=test_user, role="owner"
)

db.add(package_member)

if channel_index == 0:
package = Package(name='xtensor', description='Description of xtensor')
package = Package(name="xtensor", description="Description of xtensor")
channel.packages.append(package)

test_user = testUsers[random.randint(0, len(testUsers) - 1)]
package_member = PackageMember(
package=package, channel=channel, user=test_user, role='owner'
package=package, channel=channel, user=test_user, role="owner"
)

db.add(package_member)

# create API key
key = 'E_KaBFstCKI9hTdPM7DQq56GglRHf2HW7tQtq6si370'
key = "E_KaBFstCKI9hTdPM7DQq56GglRHf2HW7tQtq6si370"

key_user = User(id=uuid.uuid4().bytes)

api_key = ApiKey(
key=key, description='test API key', user=key_user, owner=test_user
key=key, description="test API key", user=key_user, owner=test_user
)
db.add(api_key)

key_package_member = PackageMember(
user=key_user,
channel_name=channel.name,
package_name=package.name,
role='maintainer',
role="maintainer",
)
db.add(key_package_member)

Expand All @@ -97,7 +97,7 @@ def init_test_db():
channel_member = ChannelMember(
channel=channel,
user=testUsers[random.randint(0, len(testUsers) - 1)],
role='owner',
role="owner",
)

db.add(channel_member)
Expand All @@ -106,5 +106,5 @@ def init_test_db():
db.close()


if __name__ == '__main__':
if __name__ == "__main__":
init_test_db()
2 changes: 1 addition & 1 deletion plugins/quetz_conda_suggest/quetz_conda_suggest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def generate_channel_suggest_map(db, channel_name, subdir):
subq = (
db.query(
PackageVersion.package_name,
func.max(PackageVersion.version).label('max_version'),
func.max(PackageVersion.version).label("max_version"),
)
.filter(PackageVersion.channel_name == channel_name)
.filter(PackageVersion.platform == subdir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,33 @@
Create Date: 2020-11-26 00:15:03.617759
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = 'c726f33caeeb'
revision = "c726f33caeeb"
down_revision = None
branch_labels = ('quetz-conda_suggest',)
depends_on = 'quetz'
branch_labels = ("quetz-conda_suggest",)
depends_on = "quetz"


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
'quetz_conda_suggest_metadata',
sa.Column('version_id', sa.LargeBinary(length=16), nullable=False),
sa.Column('data', sa.String(), nullable=True),
"quetz_conda_suggest_metadata",
sa.Column("version_id", sa.LargeBinary(length=16), nullable=False),
sa.Column("data", sa.String(), nullable=True),
sa.ForeignKeyConstraint(
['version_id'],
['package_versions.id'],
["version_id"],
["package_versions.id"],
),
sa.PrimaryKeyConstraint('version_id'),
sa.PrimaryKeyConstraint("version_id"),
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('quetz_conda_suggest_metadata')
op.drop_table("quetz_conda_suggest_metadata")
# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion plugins/quetz_conda_suggest/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def package(dao, user, channel, db):

@fixture
def package_version(user, channel, db, dao, package):
package_format = 'tarbz2'
package_format = "tarbz2"
package_info = '{"size": 5000, "subdir": "linux-64"}'

version = dao.create_version(
Expand Down
Loading

0 comments on commit 0f91f08

Please sign in to comment.