Skip to content

Commit

Permalink
Ignore matplotlib.pyplot typing problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
toonarmycaptain committed Jul 5, 2024
1 parent b7ee9de commit ba6ab10
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
4 changes: 3 additions & 1 deletion dionysus_app/persistence/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ def create_chart(self, chart_data_dict: dict) -> None:
"""

@abc.abstractmethod
def save_chart_image(self, chart_data_dict: dict, mpl_plt: plt) -> Path:
def save_chart_image(self, chart_data_dict: dict,
mpl_plt: plt, # type: ignore
) -> Path:
"""
Save chart image, return Path to location.
Expand Down
6 changes: 4 additions & 2 deletions dionysus_app/persistence/databases/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ def create_chart(self, chart_data_dict: dict) -> None:
with open(chart_data_filepath, 'w') as chart_data_file:
chart_data_file.write(json_chart_data)

def save_chart_image(self, chart_data_dict: dict, mpl_plt: plt) -> Path:
def save_chart_image(self, chart_data_dict: dict,
mpl_plt: plt, # type: ignore
) -> Path:
"""
Save image, and return path to file in application storage.
Expand All @@ -265,7 +267,7 @@ def save_chart_image(self, chart_data_dict: dict, mpl_plt: plt) -> Path:
Path.mkdir(app_data_save_pathname.parent, parents=True, exist_ok=True)
# Save in app_data/class_data/class_id/chart_data with chart_default_filename

mpl_plt.savefig(app_data_save_pathname, format='png',
mpl_plt.savefig(app_data_save_pathname, format='png', # type: ignore[attr-defined]
dpi=300) # dpi - 120 comes to 1920*1080, 80 - 1280*720
return app_data_save_pathname

Expand Down
6 changes: 4 additions & 2 deletions dionysus_app/persistence/databases/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ def create_chart(self, chart_data_dict: dict) -> None:
conn.commit()
conn.close()

def save_chart_image(self, chart_data_dict: dict, mpl_plt: plt) -> Path:
def save_chart_image(self, chart_data_dict: dict,
mpl_plt: plt, # type: ignore
) -> Path:
"""
Save image in db, and return path to file in temp storage.
Expand All @@ -269,7 +271,7 @@ def save_chart_image(self, chart_data_dict: dict, mpl_plt: plt) -> Path:
"""
# Get image data:
image = BytesIO()
mpl_plt.savefig(image,
mpl_plt.savefig(image, # type: ignore[attr-defined]
format='png',
dpi=300) # dpi - 120 comes to 1920*1080, 80 - 1280*720
image.seek(0) # Return pointer to start of binary stream.
Expand Down
9 changes: 6 additions & 3 deletions dionysus_app/persistence/databases/sqlite_sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
from pathlib import Path
from typing import (Any,
Iterator,
Optional,
Optional, Tuple,
)

import matplotlib
from matplotlib import pyplot as plt
from sqlalchemy import (BLOB,
Column,
Expand Down Expand Up @@ -218,7 +219,9 @@ def create_chart(self, chart_data_dict: dict) -> None:

session.add_all(student_scores_data)

def save_chart_image(self, chart_data_dict: dict, mpl_plt: plt) -> Path:
def save_chart_image(self, chart_data_dict: dict,
mpl_plt: plt, # type:ignore
) -> Path:
"""
Save image in db, and return path to file in temp storage.
Expand All @@ -228,7 +231,7 @@ def save_chart_image(self, chart_data_dict: dict, mpl_plt: plt) -> Path:
"""
# Get image data:
image = BytesIO()
mpl_plt.savefig(image,
mpl_plt.savefig(image, # type: ignore[attr-defined]
format='png',
dpi=300) # dpi - 120 comes to 1920*1080, 80 - 1280*720
image.seek(0) # Return pointer to start of binary stream.
Expand Down

0 comments on commit ba6ab10

Please sign in to comment.