Skip to content

Commit

Permalink
Merge pull request michabirklbauer#6 from michabirklbauer/develop
Browse files Browse the repository at this point in the history
add ruff and pyright
  • Loading branch information
michabirklbauer authored Nov 20, 2024
2 parents c2f5cff + 02da1b4 commit 6c26053
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 74 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/pyright.yml
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
28 changes: 28 additions & 0 deletions .github/workflows/ruff.yml
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
27 changes: 14 additions & 13 deletions docs_src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,38 @@

import os
import sys
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'Example'
copyright = '2024, Micha Johannes Birklbauer'
author = 'Micha Johannes Birklbauer'
release = '1.0.0'
project = "Example"
copyright = "2024, Micha Johannes Birklbauer"
author = "Micha Johannes Birklbauer"
release = "1.0.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode'
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
]

templates_path = ['_templates']
exclude_patterns = ['build']
templates_path = ["_templates"]
exclude_patterns = ["build"]
root_doc = "index"
autosummary_generate = True
autodoc_default_options = {"members": True, "inherited-members": True}

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'pydata_sphinx_theme'
html_static_path = ['_static']
html_theme = "pydata_sphinx_theme"
html_static_path = ["_static"]
html_theme_options = {
"icon_links": [
{
Expand Down
79 changes: 45 additions & 34 deletions gui/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# https://github.com/michabirklbauer/
# [email protected]

## disable unused variable checks for streamlit variables

# ruff: noqa: F841

"""
#####################################################
## ##
Expand All @@ -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)

Expand All @@ -89,6 +100,6 @@ def main():

main_page()

if __name__ == "__main__":

if __name__ == "__main__":
main()
58 changes: 35 additions & 23 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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()
12 changes: 12 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"include": [
"."
],

"exclude": [
"**/__pycache__"
],

"pythonVersion": "3.7",
"pythonPlatform": "Linux"
}
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pandas
pandas
streamlit
Loading

0 comments on commit 6c26053

Please sign in to comment.