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

Upgrade dependencies to newer versions #12

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
14 changes: 7 additions & 7 deletions danger_python/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
from danger_python.shell import execute_dangerfile, invoke_danger


@click.group(cls=DefaultGroup, default="run", default_if_no_args=True)
@click.group(cls=DefaultGroup)
def cli() -> None:
pass


@cli.command()
def run() -> None:
@danger_command(cli, "runner")
def run(arguments: List[str]) -> None:
print(arguments)
"""Runs dangerfile.py as a danger process"""
with open("dangerfile.py", "r") as dangerfile:
try:
Expand Down Expand Up @@ -45,9 +46,8 @@ def ci(arguments: List[str]) -> None:


def _execute_danger_js(command_name: str, arguments: List[str]) -> None:
command = [command_name]
command.extend(arguments)

process = invoke_danger(command)
process = invoke_danger(command_name, arguments)
click.echo(process.stdout)
if process:
click.echo(process.stderr, err=True)
sys.exit(process.returncode)
14 changes: 12 additions & 2 deletions danger_python/generator/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from itertools import chain
from operator import attrgetter
from typing import Iterable, List, Optional
import re

import stringcase

Expand Down Expand Up @@ -178,11 +179,20 @@ def _property(name: str, type_name: str, known_type: bool) -> PropertyDefinition
return PropertyDefinition(
name=stringcase.snakecase(patched_name),
key=name,
value_type=type_name,
value_type=strip_non_alpha_and_capitalize(type_name),
known_type=known_type,
)

def strip_non_alpha_and_capitalize(name: str) -> str:
reserved_types = ("int", "bool", "str", "list", "dict")
if name in reserved_types:
return name

stripped_name:str = re.sub('[^0-9a-zA-Z\[\]]+', ' ', name)
parts = stripped_name.split()
parts_cap = [word[0].upper() + word[1:] for word in parts]
return "".join(parts_cap)

def _nested_object_name(parent_object: SchemaItem, prefix: Optional[str] = None) -> str:
object_name = stringcase.pascalcase(parent_object.name)
object_name = stringcase.pascalcase(strip_non_alpha_and_capitalize(parent_object.name))
return f"{prefix}{object_name}" if prefix else object_name
Loading