GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - nitheesh-me/python at b4d2d559f238780140e555c3aa22b761c187d240

BranchesTags
Open more actions menu

Latest commit

 

History

119 Commits
119 Commits

Folders and files

NameName
Last commit message
Last commit date
danger_python
danger_python
 
 
scripts
scripts
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
dangerfile.py
dangerfile.py
 
 
poetry.lock
poetry.lock
 
 
pyproject.toml
pyproject.toml
 
 
setup.cfg
setup.cfg
 
 

Repository files navigation

python

Write your Dangerfiles in Python.

Requirements

Running danger-python requires:

  • Python 3.7 (tested under Python 3.7.5)
  • danger-js 9.2 (tested under danger-js 9.2.10)

Installation

⚠️ The script is currently work in progress. Installation requires:

  • Poetry 1.0.2

In order to test the script please run the following commands:

# install danger
npm install -g danger
# install poetry
pip install poetry
# install project dependencies
poetry install --no-dev
# activate virtual environment
poetry shell
# run danger-python
danger-python pr https://github.com/microsoft/TypeScript/pull/34806

dangerfile.py

You can choose between shorter untyped version of dangerfile.py:

title = danger.github.pr.title
markdown(title)

Or more verbose typed version:

from danger_python import Danger, markdown

danger = Danger()
title = danger.github.pr.title
markdown(title)

Development

To develop the code, clone the repository and run the following commands:

# install danger
npm install -g danger
# install poetry
pip install poetry
# install project dependencies
poetry install
# activate virtual environment
poetry shell
# run tests
pytest

To regenerate the input JSONSchema, put the latest version in scripts/input_schema.json and run the following commands:

cd scripts
python generate_scheme.py

This should update the danger_python/models.py file.

Building plugins

To build a plugin, add a danger-python as a dependency and subclass the DangerPlugin class:

from danger_python.plugins import DangerPlugin

class ExamplePlugin(DangerPlugin):
    def hello_world(self):
        count = len(self.danger.git.modified_files)
        self.message(f"ExamplePlugin says hello to {count} modified files")

Importing the package in a dangerfile.py will import all the instance methods to the module-level globals:

import example_plugin 

# calls hello_world method from the plugin class
example_plugin.hello_world()

TODOs

  • Parse complete Danger DSL
  • Plugin infrastructure
  • Release the initial version of the package

About

⚠️ Stop saying "you forgot to …" in code review

danger.systems/python

Resources

Readme
License
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.