Skip to content

Commit

Permalink
feat: version up to v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
diohabara committed Jun 23, 2024
1 parent 8c9f53d commit ecbe81f
Show file tree
Hide file tree
Showing 19 changed files with 187 additions and 224 deletions.
46 changes: 25 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
name: CI
on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
ci:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
lint:
name: lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"
- name: Install
run: |
poetry install
poetry run pre-commit install
- name: Lint
- uses: actions/checkout@v4

- name: Install Rye
run: |
poetry run pre-commit run --files .pre-commit-config.yaml
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: 0.24.0
RYE_INSTALL_OPTION: "--yes"

- name: Install dependencies
run: rye sync --all-features

- name: Run lints
run: pre-commit
Empty file modified bin/publish-pypi
100644 → 100755
Empty file.
12 changes: 6 additions & 6 deletions example/decompiled/01_decompiled_example_variables.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name = 'John Doe'
name = "John Doe"
age = 30
height = 6.1
age_next_year = age + 1
half_height = height / 2

print('Name:', name)
print('Age:', age)
print('Height:', height, 'feet')
print('Age next year:', age_next_year)
print('Half height:', half_height, 'feet')
print("Name:", name)
print("Age:", age)
print("Height:", height, "feet")
print("Age next year:", age_next_year)
print("Half height:", half_height, "feet")
22 changes: 11 additions & 11 deletions example/decompiled/02_decompiled_example_data_types.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
integer_example = 42
float_example = 3.14
string_example = 'Hello, World!'
string_example = "Hello, World!"
list_example = [1, 2, 3, 4, 5]
tuple_example = (1, 'apple', 3.14)
dict_example = {'name': 'John Doe', 'age': 30, 'city': 'New York'}
tuple_example = (1, "apple", 3.14)
dict_example = {"name": "John Doe", "age": 30, "city": "New York"}
set_example = {1, 2, 3, 4, 5}.union(frozenset({1, 2, 3, 4, 5}))
bool_example = True

print('Integer:', integer_example)
print('Float:', float_example)
print('String:', string_example)
print('List:', list_example)
print('Tuple:', tuple_example)
print('Dictionary:', dict_example)
print('Set:', set_example)
print('Boolean:', bool_example)
print("Integer:", integer_example)
print("Float:", float_example)
print("String:", string_example)
print("List:", list_example)
print("Tuple:", tuple_example)
print("Dictionary:", dict_example)
print("Set:", set_example)
print("Boolean:", bool_example)
26 changes: 13 additions & 13 deletions example/decompiled/03_decompiled_example_if_else.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
age = 25
country = 'USA'
job_status = 'employed'
favorite_color = 'blue'
country = "USA"
job_status = "employed"
favorite_color = "blue"

if age < 18 or (country == 'USA' and favorite_color == 'blue'):
if job_status == 'employed':
print('Minor or USA + blue, employed.')
if age < 18 or (country == "USA" and favorite_color == "blue"):
if job_status == "employed":
print("Minor or USA + blue, employed.")
else:
print('Minor or USA + blue, unemployed.')
print("Minor or USA + blue, unemployed.")
else:
if job_status == 'employed':
if country != 'USA' or favorite_color != 'blue':
print('Not minor, not USA + blue, employed.')
if job_status == "employed":
if country != "USA" or favorite_color != "blue":
print("Not minor, not USA + blue, employed.")
else:
if country != 'USA' or favorite_color != 'blue':
print('Not minor, not USA + blue, unemployed.')
if country != "USA" or favorite_color != "blue":
print("Not minor, not USA + blue, unemployed.")
else:
print('Not minor, not USA + blue, other status.')
print("Not minor, not USA + blue, other status.")
12 changes: 6 additions & 6 deletions example/decompiled/04_decompiled_example_loops.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
fruits = ('apple', 'banana', 'orange', 'grape')
fruits = ("apple", "banana", "orange", "grape")
for fruit in fruits:
print('Current fruit: {}'.format(fruit))
print("Current fruit: {}".format(fruit))
for i in range(5):
print('Current value of i: {}'.format(i))
print("Current value of i: {}".format(i))
count = 0
while count < 5:
print('Current count: {}'.format(count))
print("Current count: {}".format(count))
count += 1
for i in range(3):
print('Outer loop, i: {}'.format(i))
print("Outer loop, i: {}".format(i))
for j in range(2):
print(' Inner loop, j: {}'.format(j))
print(" Inner loop, j: {}".format(j))
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
transpose = [[row[i] for row in matrix] for i in range(len(matrix))]
print(transpose)
print(transpose)
15 changes: 9 additions & 6 deletions example/decompiled/06_decompiled_example_functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
global_var = "I'm a global variable"


def outer_function():
outer_local_var = "I'm a local variable in the outer function"

Expand All @@ -13,19 +14,21 @@ def inner_function():
print("Outer function: ", global_var)
inner_function()


def calculate(operation, a, b):
if operation == 'add':
if operation == "add":
return a + b
elif operation == 'subtract':
elif operation == "subtract":
return a - b
elif operation == 'multiply':
elif operation == "multiply":
return a * b
elif operation == 'divide':
elif operation == "divide":
return a / b
else:
return None


multiply = lambda x, y: x * y

print(calculate('add', 4, 5))
print(multiply(3, 4))
print(calculate("add", 4, 5))
print(multiply(3, 4))
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ def describe_color(self):

cat.speak()
cat.describe()
cat.describe_color()
cat.describe_color()
10 changes: 6 additions & 4 deletions example/decompiled/08_decompiled_example_modules_packages.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from animals.mammals import get_mammals, get_mammal_info


def main():
mammals = get_mammals()
print('Mammals:')
print("Mammals:")
for mammal in mammals:
print(mammal)
print('\nMammal info:')
print("\nMammal info:")
for mammal in mammals:
print(get_mammal_info(mammal))

if __name__ == '__main__':
main()

if __name__ == "__main__":
main()
30 changes: 17 additions & 13 deletions example/decompiled/09_decompiled_example_exceptioins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ def divide(a, b):
try:
result = a / b
except ZeroDivisionError:
print('Cannot divide by zero.')
print("Cannot divide by zero.")
else:
print(f'{a} divided by {b} is {result}')
print(f"{a} divided by {b} is {result}")


def safe_conversion(value, to_int=True):
try:
Expand All @@ -13,37 +14,40 @@ def safe_conversion(value, to_int=True):
else:
converted = float(value)
except ValueError:
print(f'Invalid value: {value}')
print(f"Invalid value: {value}")
except TypeError:
print(f'Unsupported type: {type(value).__name__}')
print(f"Unsupported type: {type(value).__name__}")
else:
print(f'Converted {value} to {converted}')
print(f"Converted {value} to {converted}")


def read_file(file_name):
try:
file = open(file_name, 'r')
file = open(file_name, "r")
except FileNotFoundError:
print('File not found.')
print("File not found.")
else:
content = file.read()
print(f'File content:\n{content}')
print(f"File content:\n{content}")
try:
locals()['file']
locals()["file"]
except KeyError:
pass
else:
if not file.closed:
file.close()
print('File closed.')
print("File closed.")
raise


class InvalidAgeError(ValueError):
pass


def check_age(age):
if age < 0:
raise InvalidAgeError('Age cannot be negative.')
raise InvalidAgeError("Age cannot be negative.")
elif age > 120:
raise InvalidAgeError('Age is too high.')
raise InvalidAgeError("Age is too high.")
else:
print('Age is valid.')
print("Age is valid.")
40 changes: 20 additions & 20 deletions example/decompiled/10_decompiled_example_file_io.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
file_name = 'example.txt'
file_name = "example.txt"

with open(file_name, 'r') as file:
with open(file_name, "r") as file:
content = file.read()

print('File content:\n{}'.format(content))
print("File content:\n{}".format(content))

try:
with open('output.txt', 'w') as file:
content = 'Hello, World!'
with open("output.txt", "w") as file:
content = "Hello, World!"
file.write(content)

print('Wrote content to {}'.format(file_name))
print("Wrote content to {}".format(file_name))
except:
pass

try:
with open('log.txt', 'a') as file:
log_entry = 'This is a log entry.'
file.write('{}\n'.format(log_entry))
with open("log.txt", "a") as file:
log_entry = "This is a log entry."
file.write("{}\n".format(log_entry))

print('Appended log entry to {}'.format(file_name))
print("Appended log entry to {}".format(file_name))
except:
pass

file_name = 'example.txt'
file_name = "example.txt"

print('Reading {} line by line:'.format(file_name))
with open(file_name, 'r') as file:
print("Reading {} line by line:".format(file_name))
with open(file_name, "r") as file:
for line in file:
print(line.strip())

import json

file_name = 'data.json'
data = {'name': 'John', 'age': 30, 'city': 'New York'}
file_name = "data.json"
data = {"name": "John", "age": 30, "city": "New York"}

with open(file_name, 'w') as file:
with open(file_name, "w") as file:
json.dump(data, file)

print('Wrote JSON data to {}'.format(file_name))
print("Wrote JSON data to {}".format(file_name))

with open(file_name, 'r') as file:
with open(file_name, "r") as file:
loaded_data = json.load(file)

print('Read JSON data from {}:'.format(file_name))
print(loaded_data)
print("Read JSON data from {}:".format(file_name))
print(loaded_data)
Loading

0 comments on commit ecbe81f

Please sign in to comment.