forked from michabirklbauer/python_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request michabirklbauer#6 from michabirklbauer/develop
add ruff and pyright
- Loading branch information
Showing
9 changed files
with
226 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Type-checking with Pyright | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
pyright: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install pyright | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Type-check with Pyright | ||
run: | | ||
pyright --warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Ruff Linting and Formatting | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
ruff: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install ruff | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Lint with Ruff | ||
run: | | ||
ruff check | ||
- name: Check format with Ruff | ||
run: | | ||
ruff format --check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,10 @@ | |
# https://github.com/michabirklbauer/ | ||
# [email protected] | ||
|
||
## disable unused variable checks for streamlit variables | ||
|
||
# ruff: noqa: F841 | ||
|
||
""" | ||
##################################################### | ||
## ## | ||
|
@@ -16,62 +20,69 @@ | |
import streamlit as st | ||
from main import my_product | ||
|
||
|
||
# main page content | ||
def main_page(): | ||
|
||
title = st.title("TITLE") | ||
|
||
general_description = \ | ||
""" | ||
general_description = """ | ||
DESCRIPTION | ||
""" | ||
description = st.markdown(general_description) | ||
|
||
header_1 = st.subheader("Product", divider = "rainbow") | ||
|
||
f1 = st.number_input("Number 1:", | ||
min_value = 1, | ||
max_value = 10000, | ||
value = 1, | ||
step = 1, | ||
help = "First factor of multiplication.") | ||
|
||
f2 = st.number_input("Number 2:", | ||
min_value = 1, | ||
max_value = 10000, | ||
value = 2, | ||
step = 1, | ||
help = "Second factor of multiplication.") | ||
header_1 = st.subheader("Product", divider="rainbow") | ||
|
||
f1 = st.number_input( | ||
"Number 1:", | ||
min_value=1, | ||
max_value=10000, | ||
value=1, | ||
step=1, | ||
help="First factor of multiplication.", | ||
) | ||
|
||
f2 = st.number_input( | ||
"Number 2:", | ||
min_value=1, | ||
max_value=10000, | ||
value=2, | ||
step=1, | ||
help="Second factor of multiplication.", | ||
) | ||
|
||
l1, l2, center_button, r1, r2 = st.columns(5) | ||
|
||
with center_button: | ||
compute = st.button("Compute!", type = "primary") | ||
compute = st.button("Compute!", type="primary") | ||
|
||
if compute: | ||
st.success(f"The product of {f1} and {f2} is {my_product(f1, f2)}") | ||
st.success(f"The product of {f1} and {f2} is {my_product(int(f1), int(f2))}") | ||
|
||
|
||
# side bar and main page loader | ||
def main(): | ||
|
||
about_str = \ | ||
""" | ||
about_str = """ | ||
ABOUT | ||
""" | ||
|
||
st.set_page_config(page_title = "TITLE", | ||
page_icon = ":test_tube:", | ||
layout = "wide", | ||
initial_sidebar_state = "expanded", | ||
menu_items = {"Get Help": "https://github.com/YOUR_REPO/discussions", | ||
"Report a bug": "https://github.com/YOUR_REPO/issues", | ||
"About": about_str} | ||
) | ||
st.set_page_config( | ||
page_title="TITLE", | ||
page_icon=":test_tube:", | ||
layout="wide", | ||
initial_sidebar_state="expanded", | ||
menu_items={ | ||
"Get Help": "https://github.com/YOUR_REPO/discussions", | ||
"Report a bug": "https://github.com/YOUR_REPO/issues", | ||
"About": about_str, | ||
}, | ||
) | ||
|
||
title = st.sidebar.title("TITLE") | ||
|
||
logo = st.sidebar.image("https://user-images.githubusercontent.com/7164864/217935870-c0bc60a3-6fc0-4047-b011-7b4c59488c91.png", | ||
caption = "CAPTION") | ||
logo = st.sidebar.image( | ||
"https://user-images.githubusercontent.com/7164864/217935870-c0bc60a3-6fc0-4047-b011-7b4c59488c91.png", | ||
caption="CAPTION", | ||
) | ||
|
||
doc = st.sidebar.markdown(about_str) | ||
|
||
|
@@ -89,6 +100,6 @@ def main(): | |
|
||
main_page() | ||
|
||
if __name__ == "__main__": | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,22 +5,31 @@ | |
# https://github.com/michabirklbauer/ | ||
# [email protected] | ||
|
||
|
||
##### REQUIREMENTS ###### | ||
|
||
# pip install pandas | ||
|
||
######################### | ||
|
||
# import packages | ||
import argparse | ||
# import pandas as pd | ||
|
||
######## VERSION ######## | ||
|
||
# version tracking | ||
__version = "1.0.0" | ||
__date = "2024-03-11" | ||
|
||
# REQUIREMENTS | ||
# pip install pandas | ||
|
||
###### PARAMETERS ####### | ||
|
||
param_1 = 1 | ||
param_2 = 2 | ||
|
||
######################### | ||
|
||
docs = \ | ||
""" | ||
docs = """ | ||
DESCRIPTION: | ||
A description of the script [multiplies two integers]. | ||
USAGE: | ||
|
@@ -39,17 +48,12 @@ | |
Show program's version number and exit. | ||
""" | ||
|
||
######################### | ||
|
||
# import packages | ||
import argparse | ||
import pandas as pd | ||
|
||
####### FUNCTIONS ####### | ||
|
||
# these examples use the numpy docstring style | ||
# https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard | ||
|
||
|
||
def my_product(x: int, y: int) -> int: | ||
"""Returns the product of two integer numbers. | ||
|
@@ -75,9 +79,11 @@ def my_product(x: int, y: int) -> int: | |
|
||
return x * y | ||
|
||
|
||
##### MAIN FUNCTION ##### | ||
|
||
def main(argv = None) -> int: | ||
|
||
def main(argv=None) -> int: | ||
"""Main function. | ||
Parameters | ||
|
@@ -102,25 +108,31 @@ def main(argv = None) -> int: | |
""" | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-f1", "--factor1", | ||
dest = "f1", | ||
required = True, | ||
help = "First factor of multiplication.", | ||
type = int) | ||
parser.add_argument("-f2", "--factor2", | ||
dest = "f2", | ||
default = 2, | ||
help = "Second factor of multiplication.", | ||
type = int) | ||
parser.add_argument( | ||
"-f1", | ||
"--factor1", | ||
dest="f1", | ||
required=True, | ||
help="First factor of multiplication.", | ||
type=int, | ||
) | ||
parser.add_argument( | ||
"-f2", | ||
"--factor2", | ||
dest="f2", | ||
default=2, | ||
help="Second factor of multiplication.", | ||
type=int, | ||
) | ||
args = parser.parse_args(argv) | ||
|
||
p = my_product(args.f1, args.f2) | ||
print(f"The product of {args.f1} * {args.f2} = {p}") | ||
|
||
return p | ||
|
||
|
||
######## SCRIPT ######### | ||
|
||
if __name__ == "__main__": | ||
|
||
m = main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"include": [ | ||
"." | ||
], | ||
|
||
"exclude": [ | ||
"**/__pycache__" | ||
], | ||
|
||
"pythonVersion": "3.7", | ||
"pythonPlatform": "Linux" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pandas | ||
pandas | ||
streamlit |
Oops, something went wrong.