Skip to content

Commit

Permalink
[API] Fix type error for python 3.7 and 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Aedial committed May 23, 2023
1 parent 962e6d7 commit e54d6e4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions novelai_api/ImagePreset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import enum
import json
import math
import os
import random
from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Union

Expand Down Expand Up @@ -394,7 +395,7 @@ def calculate_cost(self, is_opus: bool):
return per_sample * (n_samples - int(opus_discount))

@classmethod
def from_file(cls, path: str) -> "ImagePreset":
def from_file(cls, path: Union[str, bytes, os.PathLike, int]) -> "ImagePreset":
"""
Write the preset to a file
Expand All @@ -406,7 +407,7 @@ def from_file(cls, path: str) -> "ImagePreset":

return cls(**data)

def to_file(self, path: str):
def to_file(self, path: Union[str, bytes, os.PathLike, int]):
"""
Load the preset from a file
Expand Down
2 changes: 1 addition & 1 deletion novelai_api/Preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def from_preset_data(cls, data: Optional[Dict[str, Any]] = None, **kwargs) -> "P
return c

@classmethod
def from_file(cls, path: Union[str, bytes, os.PathLike[str], os.PathLike[bytes], int]) -> "Preset":
def from_file(cls, path: Union[str, bytes, os.PathLike, int]) -> "Preset":
"""
Instantiate a preset from the given file
Expand Down
2 changes: 1 addition & 1 deletion novelai_api/scripts.py → novelai_api/poetry_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ def bump_version():
_run("git", "tag", "-a", f"v{bumped_version}")

print(
f"You can now push the commit and the tag with `git push origin v{bumped_version}`.\n"
"You can now push the commit and the tag with `git push --follow-tags`.\n"
"Ensure you're really ready to push with `git status` and `git log`."
)
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ asyncio_mode = "auto"
addopts = "--tb=short -vv"

[tool.poetry.scripts]
nai-pre-commit = "novelai_api.scripts:pre_commit"
nai-test-mock = "novelai_api.scripts:test_mock"
nai-test-api = "novelai_api.scripts:test_api"
nai-build-docs = "novelai_api.scripts:build_docs"
nai-bump-version = "novelai_api.scripts:bump_version"
nai-pre-commit = "novelai_api.poetry_scripts:pre_commit"
nai-test-mock = "novelai_api.poetry_scripts:test_mock"
nai-test-api = "novelai_api.poetry_scripts:test_api"
nai-build-docs = "novelai_api.poetry_scripts:build_docs"
nai-bump-version = "novelai_api.poetry_scripts:bump_version"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit e54d6e4

Please sign in to comment.