-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
187 additions
and
224 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 |
---|---|---|
@@ -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.
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,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") |
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,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) |
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,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.") |
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,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)) |
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
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 |
---|---|---|
|
@@ -47,4 +47,4 @@ def describe_color(self): | |
|
||
cat.speak() | ||
cat.describe() | ||
cat.describe_color() | ||
cat.describe_color() |
10 changes: 6 additions & 4 deletions
10
example/decompiled/08_decompiled_example_modules_packages.py
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,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() |
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 |
---|---|---|
@@ -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) |
Oops, something went wrong.