Skip to content

Commit

Permalink
fix type checkign
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Aug 6, 2024
1 parent 2ed6bb7 commit 23f3625
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/rattler_build_conda_compat/modify_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io
import logging
import re
from typing import TYPE_CHECKING, Any, Literal
from typing import TYPE_CHECKING, Any, Literal, Set

import requests
from ruamel.yaml import YAML
Expand All @@ -18,6 +18,8 @@

logger = logging.getLogger(__name__)

HashType = Literal["md5", "sha256"]

yaml = YAML()
yaml.preserve_quotes = True
yaml.width = 4096
Expand Down Expand Up @@ -81,7 +83,7 @@ def __init__(self, message: str = "Could not update version") -> None:


class Hash:
def __init__(self, hash_type: Literal["md5", "sha256"], hash_value: str) -> None:
def __init__(self, hash_type: HashType, hash_value: str) -> None:
self.hash_type = hash_type
self.hash_value = hash_value

Expand All @@ -105,9 +107,9 @@ def update_hash(source: Source, url: str, hash_: Hash | None) -> None:
* `url` - The URL to download and hash (if no hash is provided).
* `hash_` - The hash to use. If not provided, the file will be downloaded and `sha256` hashed.
"""
hash_type = hash_.hash_type if hash_ is not None else "sha256"
hash_type : HashType = hash_.hash_type if hash_ is not None else "sha256"
# delete all old hashes that we are not updating
all_hash_types = {"md5", "sha256"}
all_hash_types: Set[HashType] = {"md5", "sha256"}
for key in all_hash_types - {hash_type}:
if key in source:
del source[key]
Expand Down

0 comments on commit 23f3625

Please sign in to comment.