Skip to content

Commit

Permalink
update pre-commit versions (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv authored Feb 9, 2023
1 parent 6cdf96e commit 2a92258
Show file tree
Hide file tree
Showing 67 changed files with 14 additions and 309 deletions.
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.7.0
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 3.8.4
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-use-fstring
- repo: https://github.com/pre-commit/mirrors-mypy
# Note: updating to v1.0.0 a bit more work
rev: v0.902
hooks:
- id: mypy
Expand Down
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 @@ -93,7 +93,7 @@ def generate_channel_suggest_map(db, channel_name, subdir):
pass
else:
files_data = json.loads(each_package.binfiles.data)
for (k, v) in files_data.items():
for k, v in files_data.items():
channel_suggest_map[k] = v

fname = f"{channel_name}.{subdir}.map"
Expand Down
1 change: 0 additions & 1 deletion plugins/quetz_content_trust/quetz_content_trust/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def post_role(
)

def get_self_delegation(nullable: bool = False):

query = (
db.query(db_models.RoleDelegation)
.filter(
Expand Down
1 change: 0 additions & 1 deletion plugins/quetz_content_trust/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ def pkg_mgr_role_file(tmp_path, offline_keys, signing_key):
def signed_package(
client, channel, root_role_file, key_mgr_role_file, pkg_mgr_role_file
):

client.post(
f"/api/content-trust/{channel.name}/roles?type=root",
files={"file": (root_role_file.name, open(root_role_file, 'rb'))},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@


class DictionaryAuthenticator(SimpleAuthenticator):

passwords: dict
provider = "dict"

def configure(self, config: Config):

config.register(
[
ConfigSection(
Expand Down
5 changes: 0 additions & 5 deletions plugins/quetz_harvester/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def user_role():

@pytest.fixture
def user(db, user_role):

new_user = User(id=uuid.uuid4().bytes, username="bartosz", role=user_role)
profile = Profile(name="Bartosz", avatar_url="http:///avatar", user=new_user)
db.add(profile)
Expand Down Expand Up @@ -69,7 +68,6 @@ def package_version(
dao: Dao,
config: Config,
):

pkgstore = config.get_package_store()
filename = Path(__file__).parent / "data" / "xtensor-io-0.10.3-hb585cf6_0.tar.bz2"
with open(filename, "rb") as fid:
Expand Down Expand Up @@ -114,7 +112,6 @@ def package_role():

@pytest.fixture
def public_channel(dao: Dao, user, channel_role, channel_name, db):

channel_data = Channel(name=channel_name, private=False)
channel = dao.create_channel(channel_data, user.id, channel_role)

Expand All @@ -125,7 +122,6 @@ def public_channel(dao: Dao, user, channel_role, channel_name, db):

@pytest.fixture
def public_package(db, user, public_channel, dao, package_role, package_name):

package_data = Package(name=package_name)

package = dao.create_package(
Expand Down Expand Up @@ -153,7 +149,6 @@ def sqlite_in_memory():

@pytest.fixture
def api_key(db, user):

key = ApiKey(
key="apikey",
time_created=date.today(),
Expand Down
1 change: 0 additions & 1 deletion plugins/quetz_harvester/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
def test_harvest_endpoint_and_job(
api_key, auth_client, db, config, supervisor, package_version, app, channel_name
):

response = auth_client.post(
"/api/jobs", json={"items_spec": "*", "manifest": "quetz-harvester:harvest"}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def _load_instructions(tar, path):
@quetz.hookimpl(tryfirst=True)
def post_package_indexing(tempdir: Path, channel_name, subdirs, files, packages):
with get_db_manager() as db:

query = (
db.query(PackageVersion)
.filter(
Expand All @@ -131,7 +130,6 @@ def post_package_indexing(tempdir: Path, channel_name, subdirs, files, packages)
extract_ = extract_from_conda

with extract_(fs) as tar:

for subdir in subdirs:
packages[subdir] = {}
path = f"{subdir}/patch_instructions.json"
Expand Down
4 changes: 0 additions & 4 deletions plugins/quetz_repodata_patching/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def package_file_name(package_name, package_format):

@pytest.fixture
def channel(dao: "quetz.dao.Dao", channel_name, user):

channel_data = Channel(name=channel_name, private=False)
channel = dao.create_channel(channel_data, user.id, "owner")
return channel
Expand Down Expand Up @@ -137,7 +136,6 @@ def patched_package_name(package_file_name):

@pytest.fixture
def patch_content(patched_package_name, revoke_instructions, remove_instructions):

d = {}

package_file_name = patched_package_name
Expand Down Expand Up @@ -167,7 +165,6 @@ def patches_subdir():

@pytest.fixture
def repodata_archive(repodata_file_name, patch_content, archive_format, patches_subdir):

from io import BytesIO

patch_instructions = json.dumps(patch_content).encode('ascii')
Expand Down Expand Up @@ -221,7 +218,6 @@ def package_repodata_patches(
repodata_archive,
archive_format,
):

package_name = repodata_name
package_data = Package(name=package_name)

Expand Down
2 changes: 0 additions & 2 deletions plugins/quetz_repodata_zchunk/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def package_file_name(package_name, package_format):

@pytest.fixture
def channel(dao: "quetz.dao.Dao", channel_name, user):

channel_data = Channel(name=channel_name, private=False)
channel = dao.create_channel(channel_data, user.id, "owner")
return channel
Expand Down Expand Up @@ -132,7 +131,6 @@ def test_repodata_zchunk(
assert "repodata.json.zck" in content

for fname in ("repodata.json", "repodata.json.zck"):

repodata_path = os.path.join(
pkgstore.channels_dir, channel_name, "noarch", fname
)
Expand Down
1 change: 0 additions & 1 deletion plugins/quetz_runexports/quetz_runexports/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def get_run_exports(
filename: str,
db: Session = Depends(get_db),
):

package_version = (
db.query(PackageVersion)
.filter(PackageVersion.channel_name == channel_name)
Expand Down
1 change: 0 additions & 1 deletion plugins/quetz_runexports/quetz_runexports/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def post_add_package_version(version, condainfo):
run_exports = json.dumps(condainfo.run_exports)

with get_db_manager() as db:

if not version.runexports:
metadata = db_models.PackageVersionMetadata(
version_id=version.id, data=run_exports
Expand Down
2 changes: 0 additions & 2 deletions plugins/quetz_runexports/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def user(db):

@fixture
def channel(dao, user, db):

channel_data = rest_models.Channel(
name="test-mirror-channel",
private=False,
Expand Down Expand Up @@ -87,7 +86,6 @@ def package_version(user, channel, db, dao, package):

@fixture
def package_runexports(package_version, db):

meta = db_models.PackageVersionMetadata(
version_id=package_version.id,
data=json.dumps({"weak": ["somepackage > 3.0"]}),
Expand Down
5 changes: 0 additions & 5 deletions plugins/quetz_transmutation/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def user_role():

@pytest.fixture
def user(db, user_role):

new_user = User(id=uuid.uuid4().bytes, username="bartosz", role=user_role)
profile = Profile(name="Bartosz", avatar_url="http:///avatar", user=new_user)
db.add(profile)
Expand All @@ -43,7 +42,6 @@ def user(db, user_role):

@pytest.fixture
def api_key(db, user):

key = ApiKey(
key="apikey",
time_created=date.today(),
Expand Down Expand Up @@ -84,7 +82,6 @@ def package_version(
dao: Dao,
config: Config,
):

pkgstore = config.get_package_store()
filename = Path("test-package-0.1-0.tar.bz2")
with open(filename, "rb") as fid:
Expand Down Expand Up @@ -129,7 +126,6 @@ def package_role():

@pytest.fixture
def public_channel(dao: Dao, user, channel_role, channel_name, db):

channel_data = Channel(name=channel_name, private=False)
channel = dao.create_channel(channel_data, user.id, channel_role)

Expand All @@ -140,7 +136,6 @@ def public_channel(dao: Dao, user, channel_role, channel_name, db):

@pytest.fixture
def public_package(db, user, public_channel, dao, package_role, package_name):

package_data = Package(name=package_name)

package = dao.create_package(
Expand Down
3 changes: 0 additions & 3 deletions plugins/quetz_transmutation/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
async def test_transmutation_endpoint(
api_key, db, config, supervisor, package_version, app, channel_name
):

# we need to use asynchronous http client because the test is async
async with AsyncClient(app=app, base_url="http://test") as ac:
response = await ac.post(
Expand Down Expand Up @@ -76,7 +75,6 @@ async def test_transmutation_endpoint(
def test_package_specs(
auth_client, db, config, supervisor, package_version, spec, n_tasks
):

response = auth_client.post(
"/api/jobs",
json={"items_spec": spec, "manifest": "quetz-transmutation:transmutation"},
Expand Down Expand Up @@ -123,7 +121,6 @@ def test_package_specs(
],
)
def test_permissions(auth_client, db, expected_status):

response = auth_client.post(
"/api/jobs",
json={"items_spec": "*", "manifest": "quetz-transmutation:transmutation"},
Expand Down
10 changes: 3 additions & 7 deletions quetz/authentication/auth_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def create_user_with_identity(
default_role: Optional[str],
default_channels: Optional[List[str]],
) -> User:

username = profile["login"]
user = dao.create_user_with_profile(
username=username,
Expand All @@ -37,15 +36,12 @@ def create_user_with_identity(
)

if default_channels is not None:

for channel_name in default_channels:

i = 0

while (
dao.db.query(Channel).filter(Channel.name == channel_name).one_or_none()
):

channel_name = f"{username}-{i}"

i += 1
Expand Down Expand Up @@ -79,7 +75,6 @@ def user_profile_changed(user, identity, profile: 'base.UserProfile'):
def update_user_from_profile(
db: Session, user, identity, profile: 'base.UserProfile'
) -> User:

identity.username = profile['login']
user.profile.name = profile['name']
user.profile.avatar_url = profile['avatar_url']
Expand Down Expand Up @@ -128,13 +123,14 @@ def get_user_by_identity(
default_role: Optional[str] = None,
default_channels: Optional[List[str]] = None,
) -> User:

db = dao.db

try:
user, identity = db.query(User, Identity).join(Identity).filter(
Identity.provider == provider
).filter(Identity.identity_id == str(profile['id']),).one_or_none() or (
).filter(
Identity.identity_id == str(profile['id']),
).one_or_none() or (
None,
None,
)
Expand Down
4 changes: 0 additions & 4 deletions quetz/authentication/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@


class Email(TypedDict):

email: str
verified: Boolean
primary: Boolean


class UserProfile(TypedDict):

id: str
name: str
avatar_url: str
Expand Down Expand Up @@ -66,7 +64,6 @@ class BaseAuthenticationHandlers:
authorize_methods: List[str]

def __init__(self, authenticator, app=None):

self.authenticator = authenticator

# dependency_overrides_provider kwarg is needed for unit test
Expand Down Expand Up @@ -253,7 +250,6 @@ async def authenticate(


class FormHandlers(BaseAuthenticationHandlers):

authorize_methods = ["POST"]

async def login(self, request: Request):
Expand Down
2 changes: 0 additions & 2 deletions quetz/authentication/jupyterhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


class JupyterConfigEntry:

config_section = "jupyterhubauthenticator"
registered_entries: List[ConfigEntry] = []
config = None
Expand Down Expand Up @@ -160,7 +159,6 @@ async def validate_token(self, token):
return resp.status_code == 200

def configure(self, config: Config):

self.is_enabled = JupyterConfigEntry.register(config)

super().configure(config)
2 changes: 0 additions & 2 deletions quetz/authentication/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class OAuthHandlers(BaseAuthenticationHandlers):
authorize_methods = ["GET"]

def __init__(self, authenticator, app=None):

super().__init__(authenticator, app)

self.router.add_api_route("/revoke", self.revoke, methods=["GET"])
Expand Down Expand Up @@ -101,7 +100,6 @@ async def authenticate(self, request, data=None, dao=None, config=None):
return {"username": username, "profile": profile, "auth_state": auth_state}

def register(self, client_kwargs=None):

if client_kwargs is None:
client_kwargs = {}

Expand Down
2 changes: 0 additions & 2 deletions quetz/authentication/pam.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def _get_user_group_ids(self, username):
return os.getgrouplist(username, user_gid)

def configure(self, config: Config):

config_options = self._make_config()
config.register(config_options)

Expand All @@ -113,7 +112,6 @@ def configure(self, config: Config):
super().configure(config)

async def user_role(self, request: Request, profile: UserProfile):

mappings = [
(ServerRole.OWNER, self.admin_groups),
(ServerRole.MAINTAINER, self.maintainer_groups),
Expand Down
Loading

0 comments on commit 2a92258

Please sign in to comment.