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

Implement typings in conda-smithy #1957

Open
wants to merge 14 commits into
base: main
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
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: run type check
run: |
mypy conda_smithy tests
continue-on-error: true # type check is optional

- name: coveralls
uses: coverallsapp/github-action@master
with:
Expand Down
23 changes: 12 additions & 11 deletions conda_smithy/anaconda_token_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import os
import sys
from contextlib import redirect_stderr, redirect_stdout
from typing import Optional, Union

import requests
from github import Github
Expand All @@ -32,17 +33,17 @@ def _get_anaconda_token():


def rotate_anaconda_token(
user,
project,
feedstock_config_path,
drone=True,
circle=True,
travis=True,
azure=True,
appveyor=True,
github_actions=True,
token_name="BINSTAR_TOKEN",
drone_endpoints=(),
user: str,
project: str,
feedstock_config_path: Optional[str],
drone: bool = True,
circle: bool = True,
travis: bool = True,
azure: bool = True,
appveyor: bool = True,
github_actions: bool = True,
token_name: str = "BINSTAR_TOKEN",
drone_endpoints: Union[list, tuple] = (),
):
"""Rotate the anaconda (binstar) token used by the CI providers

Expand Down
22 changes: 16 additions & 6 deletions conda_smithy/ci_skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@

import os
import sys
from typing import Dict

from jinja2.sandbox import SandboxedEnvironment

from conda_smithy.configure_feedstock import make_jinja_env


def _render_template(template_file, env, forge_dir, config):
def _render_template(
template_file: str,
env: SandboxedEnvironment,
forge_dir: str,
config: Dict[str, str],
):
"""Renders the template"""
template = env.get_template(
os.path.basename(template_file) + ".ci-skel.tmpl"
Expand All @@ -31,10 +39,10 @@ def _render_template(template_file, env, forge_dir, config):


def _insert_into_gitignore(
feedstock_directory=".",
prefix="# conda smithy ci-skeleton start\n",
suffix="# conda smithy ci-skeleton end\n",
):
feedstock_directory: str = ".",
prefix: str = "# conda smithy ci-skeleton start\n",
suffix: str = "# conda smithy ci-skeleton end\n",
) -> str:
"""Places gitignore contents into gitignore."""
# get current contents
fname = os.path.join(feedstock_directory, ".gitignore")
Expand All @@ -57,7 +65,9 @@ def _insert_into_gitignore(


def generate(
package_name="pkg", feedstock_directory=".", recipe_directory="recipe"
package_name: str = "pkg",
feedstock_directory: str = ".",
recipe_directory: str = "recipe",
):
"""Generates the CI skeleton."""
forge_dir = os.path.abspath(feedstock_directory)
Expand Down
5 changes: 3 additions & 2 deletions conda_smithy/cirun_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def get_cirun_installation_id(owner: str) -> int:
else:
gh = Github(gh_token())
user = gh.get_user()
user_or_org: Any
if user.login == owner:
user_or_org = user
else:
Expand All @@ -42,8 +43,8 @@ def add_repo_to_cirun_resource(
owner: str,
repo: str,
resources: List[str],
teams: List,
roles: List,
teams: Optional[List],
roles: Optional[List],
users_from_json: Optional[str] = None,
cirun_policy_args: Optional[List[str]] = None,
) -> Dict[str, Any]:
Expand Down
14 changes: 8 additions & 6 deletions conda_smithy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import tempfile
import time
from textwrap import dedent
from typing import Optional, Union
from typing import List, Optional, Union

import conda # noqa
from conda_build.metadata import MetaData
Expand All @@ -27,12 +27,14 @@
)


def default_feedstock_config_path(feedstock_directory):
def default_feedstock_config_path(feedstock_directory: str) -> str:
return os.path.join(feedstock_directory, "conda-forge.yml")


def generate_feedstock_content(
target_directory, source_recipe_dir, conda_build_tool: Optional[str] = None
target_directory: str,
source_recipe_dir: str,
conda_build_tool: Optional[str] = None,
):
target_directory = os.path.abspath(target_directory)
recipe_dir = "recipe"
Expand Down Expand Up @@ -81,10 +83,10 @@ def generate_feedstock_content(

class Subcommand:
#: The name of the subcommand
subcommand = None
aliases = []
subcommand: Optional[str] = None
aliases: List[str] = []

def __init__(self, parser, help=None):
def __init__(self, parser, help: Optional[str] = None):
subcommand_parser = parser.add_parser(
self.subcommand, help=help, description=help, aliases=self.aliases
)
Expand Down
Loading
Loading