Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mypy type checking #88

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Graphics_and_Multimedia/Dominant_Colors/dominant_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def new_image(self):
self.bands.set("".join(image.getbands()))


def load_image(image_path: str) -> Image:
def load_image(image_path: str) -> Image.Image:
"""Return Image object of specified image."""
image = Image.open(image_path)
image.load()
Expand Down
2 changes: 1 addition & 1 deletion Graphics_and_Multimedia/Mp3_Player/mp3_player.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class MainWindow(tk.Tk):
self.treeview_frame.grid_rowconfigure(0, weight=1)
self.volume_frame.grid_rowconfigure(1, weight=1)

def play_audio(self, file: tuple = None):
def play_audio(self, file: tuple | None = None):
"""Play the currently selected file."""
selection = self.playlist_treeview.selection()

Expand Down
2 changes: 1 addition & 1 deletion Numbers/Find_Pi_to_the_Nth_digit/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import unittest

from find_pi_to_the_nth_digit import get_pi_to
from Numbers.Find_Pi_to_the_Nth_digit.find_pi_to_the_nth_digit import get_pi_to


class Test(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The original categories from *Idea Bag 2* are used to organize them.

## How to use
If you want to get the programs for playing around with them or editing them just download or clone them from Github.
All programs need [python 3.8](https://www.python.org/downloads/) or later installed,
All programs need [python 3.10](https://www.python.org/downloads/) or later installed,
and for some of them external modules are required.
Go to [Dependencies](#dependencies) to check which modules you need to install and how.

Expand All @@ -24,7 +24,7 @@ You can watch this video, which explains how to use this repository and how it i
If you want to contribute in any way please take a look at [CONTRIBUTING.md](CONTRIBUTING.md).

## Dependencies
* [Python 3.8+](https://www.python.org/downloads/)
* [Python 3.10+](https://www.python.org/downloads/)
* [Pillow](http://python-pillow.org) (Graphics and Multimedia/Dominant Colors, Threading/Bulk Thumbnail Creator)
* [Beautifulsoup](https://www.crummy.com/software/BeautifulSoup/) (Web/Page Scraper)
* [Pygame](https://www.pygame.org/) (Graphics and Multimedia/Mp3 Player)
Expand Down
2 changes: 1 addition & 1 deletion Text/CD_Key_Generator/cd_key_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import random


def generate_key(characters: tuple, length: int, file_name: str = None) -> str:
def generate_key(characters: tuple, length: int, file_name: str | None = None) -> str:
"""Return random string containing specified characters."""
random_result = random.choices(characters, k=length)
string = ""
Expand Down
4 changes: 2 additions & 2 deletions Text/Fizz_Buzz/fizz_buzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
from typing import Generator


def fizzbuzz() -> list:
def fizzbuzz() -> list[str | int]:
"""Return Fizz Buzz from 1 to 100.

Return a list of numbers from 1 to 100,
replacing multiples of three with Fizz,
multiples of five with Buzz and
multiples of both with FizzBuzz.
"""
fizzbuzz_list = []
fizzbuzz_list: list[str | int] = []
for num in range(1, 101):
if num % 3 == 0 and num % 5 == 0:
fizzbuzz_list.append("FizzBuzz")
Expand Down
52 changes: 26 additions & 26 deletions Text/RSS_Feed_Creator/rss_feed_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class RSSItem:

def __init__(self,
title: str,
link: str = None,
description: str = None,
author: str = None,
category: str = None,
comments: str = None,
enclosure: dict = None,
guid: str = None,
pub_date: datetime.datetime = None,
source: str = None):
link: str | None = None,
description: str | None = None,
author: str | None = None,
category: str | None = None,
comments: str | None = None,
enclosure: dict | None = None,
guid: str | None = None,
pub_date: datetime.datetime | None = None,
source: str | None = None):
self.title = title
self.link = link
self.description = description
Expand All @@ -48,22 +48,22 @@ def __init__(self,
channel_link: str,
channel_description: str,
items: List[RSSItem],
language: str = None,
copyright: str = None,
managing_editor: str = None,
web_master: str = None,
pub_date: datetime.datetime = None,
last_build_date: datetime.datetime = None,
category: str = None,
generator: str = None,
docs: str = None,
cloud: dict = None,
ttl: int = None,
image: dict = None,
rating: str = None,
text_input: dict = None,
skip_hours: list = None,
skip_days: list = None):
language: str | None = None,
copyright: str | None = None,
managing_editor: str | None = None,
web_master: str | None = None,
pub_date: datetime.datetime | None = None,
last_build_date: datetime.datetime | None = None,
category: str | None = None,
generator: str | None = None,
docs: str | None = None,
cloud: dict | None = None,
ttl: int | None = None,
image: dict | None = None,
rating: str | None = None,
text_input: dict | None = None,
skip_hours: list | None = None,
skip_days: list | None = None):
self.channel_title = channel_title
self.channel_link = channel_link
self.channel_description = channel_description
Expand All @@ -89,7 +89,7 @@ def __init__(self,
class RSSFile:
"""An RSS file."""

def __init__(self, file_name: str, rss_document: RSSDocument = None):
def __init__(self, file_name: str, rss_document: RSSDocument | None = None):
self.file_name = file_name
self.rss_document = rss_document

Expand Down