Skip to content

Commit

Permalink
refactor: replace dev deps to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
daxartio committed Nov 23, 2024
1 parent 0129c71 commit c1975bc
Show file tree
Hide file tree
Showing 133 changed files with 5,614 additions and 6,359 deletions.
56 changes: 28 additions & 28 deletions builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,64 @@
from sportorg import config

base = None
if sys.platform == 'win32':
base = 'Win32GUI'
if sys.platform == "win32":
base = "Win32GUI"

include_files = [
config.LOCALE_DIR,
config.TEMPLATE_DIR,
config.IMG_DIR,
config.SOUND_DIR,
config.base_dir('LICENSE'),
config.base_dir('changelog.md'),
config.base_dir('changelog_ru.md'),
config.base_dir('configs'),
config.base_dir("LICENSE"),
config.base_dir("changelog.md"),
config.base_dir("changelog_ru.md"),
config.base_dir("configs"),
config.STYLE_DIR,
]
includes = ['atexit', 'codecs', 'playsound', 'pyImpinj']
excludes = ['Tkinter', 'unittest', 'test', 'pydoc']
includes = ["atexit", "codecs", "playsound", "pyImpinj"]
excludes = ["Tkinter", "unittest", "test", "pydoc"]

build_exe_options = {
'includes': includes,
'excludes': excludes,
'packages': ['idna', 'requests', 'encodings', 'asyncio', 'pywinusb'],
'include_files': include_files,
'zip_include_packages': ['PySide6'],
'optimize': 2,
'include_msvcr': True,
'silent': 1,
"includes": includes,
"excludes": excludes,
"packages": ["idna", "requests", "encodings", "asyncio", "pywinusb"],
"include_files": include_files,
"zip_include_packages": ["PySide6"],
"optimize": 2,
"include_msvcr": True,
"silent": 1,
}

bdist_msi_options = {
'all_users': False,
'data': {
'Shortcut': [
"all_users": False,
"data": {
"Shortcut": [
(
'DesktopShortcut', # Shortcut
'DesktopFolder', # Directory
"DesktopShortcut", # Shortcut
"DesktopFolder", # Directory
config.NAME, # Name
'TARGETDIR', # Component
'[TARGETDIR]SportOrg.exe', # Target
"TARGETDIR", # Component
"[TARGETDIR]SportOrg.exe", # Target
None, # Arguments
None, # Description
None, # Hotkey
None, # Icon
None, # IconIndex
None, # ShowCmd
'TARGETDIR', # WkDir
"TARGETDIR", # WkDir
),
]
},
}

options = {'build_exe': build_exe_options, 'bdist_msi': bdist_msi_options}
options = {"build_exe": build_exe_options, "bdist_msi": bdist_msi_options}

executables = [
Executable(
'SportOrg.pyw',
"SportOrg.pyw",
base=base,
icon=config.icon_dir('sportorg.ico'),
copyright='GNU GENERAL PUBLIC LICENSE {}'.format(config.NAME),
icon=config.icon_dir("sportorg.ico"),
copyright="GNU GENERAL PUBLIC LICENSE {}".format(config.NAME),
)
]

Expand Down
2,800 changes: 1,043 additions & 1,757 deletions poetry.lock

Large diffs are not rendered by default.

33 changes: 4 additions & 29 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,20 @@ requests = "^2"
sportident = "^1"

[tool.poetry.group.dev.dependencies]
autoflake = "*"
black = ">=23"
commitizen = "^3.12.0"
cx_Freeze = "^6"
flake8 = "^6"
flake8-annotations-complexity = "*"
flake8-bandit = "*"
flake8-breakpoint = "*"
flake8-bugbear = "*"
flake8-builtins = "*"
flake8-comprehensions = "*"
flake8-eradicate = "*"
flake8-if-expr = "*"
flake8-isort = "*"
flake8-logging-format = "*"
flake8-print = "*"
flake8-pytest = "*"
flake8-pytest-style = "*"
flake8-requirements = "*"
flake8-return = "*"
mypy = "^1.4"
pep8-naming = "*"
poethepoet = "^0.22.0"
pylint = "^2.17"
pytest = "^7.4"
pytest-cov = "*"
pytest-deadfixtures = "*"
pytest-mock = "*"
ruff = "^0.8.0"
toml = "*"
types-playsound = "^1.3.1.3"
types-polib = "^1.2.0.1"
types-python-dateutil = "^2.8.19.14"
types-requests = "^2.31.0.2"
types-six = "^1.16.21.9"
unify = "*"

[tool.poetry.extras]
win = ["pywin32", "pyImpinj", "playsound"]
Expand Down Expand Up @@ -96,10 +75,9 @@ cmd = "pytest -vv --last-failed"
[tool.poe.tasks.lint]
help = "Check code"
sequence = [
{cmd = "poetry check"},
{ref = "generate-mo"},
# {cmd = "flake8 --jobs 4 --statistics --show-source ${CODE}"},
# {cmd = "pylint --jobs 1 --rcfile=setup.cfg ${CODE}"},
{cmd = "black --skip-string-normalization --line-length=88 --check ${CODE}"},
{cmd = "ruff check ${CODE}"},
{cmd = "pytest --dead-fixtures --dup-fixtures"},
# {cmd = "mypy ${CODE}"},
]
Expand All @@ -108,10 +86,7 @@ sequence = [
help = "Formating code"
sequence = [
{ref = "generate-mo"},
{cmd = "autoflake --recursive --in-place --remove-all-unused-imports ${CODE}"},
{cmd = "isort ${CODE}"},
{cmd = "black --skip-string-normalization --line-length=88 ${CODE}"},
{cmd = "unify --in-place --recursive ${CODE}"},
{cmd = "ruff format ${CODE}"},
]

[tool.poe.tasks.generate-mo]
Expand Down
2 changes: 1 addition & 1 deletion sportorg/common/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ def _run(self):
try:
play(sound)
except Exception as e:
self._logger.error('Can not play {}'.format(sound))
self._logger.error("Can not play {}".format(sound))
print(e)
2 changes: 1 addition & 1 deletion sportorg/common/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def produce(self, name, *args, **kwargs):
r = method(*args, **kwargs)
except AttributeError:
self._logger.error(
'Class `%s` does not implement `%s`',
"Class `%s` does not implement `%s`",
cls.__class__.__name__,
method_name,
)
Expand Down
24 changes: 12 additions & 12 deletions sportorg/common/otime.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ def __repr__(self):
return self.__str__()

@classmethod
def now(cls) -> 'OTime':
def now(cls) -> "OTime":
now = datetime.datetime.now()
return OTime(0, now.hour, now.minute, now.second, round(now.microsecond / 1000))

def replace(self, day=None, hour=None, minute=None, sec=None, msec=None) -> 'OTime':
def replace(self, day=None, hour=None, minute=None, sec=None, msec=None) -> "OTime":
return OTime(
self.if_none(day, self.day),
self.if_none(hour, self.hour),
Expand All @@ -99,7 +99,7 @@ def replace(self, day=None, hour=None, minute=None, sec=None, msec=None) -> 'OTi
self.if_none(msec, self.msec),
)

def copy(self) -> 'OTime':
def copy(self) -> "OTime":
return OTime(msec=self.to_msec())

def to_minute(self):
Expand All @@ -119,9 +119,9 @@ def to_time(self):

def to_minute_str(self):
minute = int(self.to_msec() / (1000 * 60))
return '{}:{}'.format(
minute if minute > 9 else '0' + str(minute),
self.sec if self.sec > 9 else '0' + str(self.sec),
return "{}:{}".format(
minute if minute > 9 else "0" + str(minute),
self.sec if self.sec > 9 else "0" + str(self.sec),
)

@staticmethod
Expand All @@ -141,18 +141,18 @@ def if_none(val: int, default: int) -> int:
def to_str(self, time_accuracy: int = 0) -> str:
hour = self.hour + self.day * 24
if time_accuracy == 0:
return f'{hour:02}:{self.minute:02}:{self.sec:02}'
return f"{hour:02}:{self.minute:02}:{self.sec:02}"
elif time_accuracy == 3:
return f'{hour:02}:{self.minute:02}:{self.sec:02}.{self.msec:003}'
return f"{hour:02}:{self.minute:02}:{self.sec:02}.{self.msec:003}"
elif time_accuracy == 2:
return f'{hour:02}:{self.minute:02}:{self.sec:02}.{self.msec // 10:02}'
return f"{hour:02}:{self.minute:02}:{self.sec:02}.{self.msec // 10:02}"
elif time_accuracy == 1:
return f'{hour:02}:{self.minute:02}:{self.sec:02}.{self.msec // 100}'
raise ValueError('time_accuracy is invalid')
return f"{hour:02}:{self.minute:02}:{self.sec:02}.{self.msec // 100}"
raise ValueError("time_accuracy is invalid")

def round(
self, time_accuracy: int = 0, time_rounding: TimeRounding = TimeRounding.math
) -> 'OTime':
) -> "OTime":
ms = self.to_msec()
multiplier = 10 ** (3 - time_accuracy)
if time_rounding == TimeRounding.math:
Expand Down
14 changes: 7 additions & 7 deletions sportorg/common/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sportorg.libs.template import template


def get_templates(path: str = '', exclude_path: str = '') -> List[str]:
def get_templates(path: str = "", exclude_path: str = "") -> List[str]:
if not path:
path = config.template_dir()
if not exclude_path:
Expand All @@ -16,20 +16,20 @@ def get_templates(path: str = '', exclude_path: str = '') -> List[str]:
if os.path.isdir(full_path):
fs = get_templates(full_path)
for f in fs:
f = f.replace(exclude_path, '')
f = f.replace('\\', '/')
f = f.replace(exclude_path, "")
f = f.replace("\\", "/")
files.append(f)
else:
full_path = full_path.replace(exclude_path, '')
full_path = full_path.replace('\\', '/')
full_path = full_path.replace(exclude_path, "")
full_path = full_path.replace("\\", "/")
files.append(full_path)

return files


def get_text_from_file(path: str, **kwargs: Any) -> str:
kwargs['name'] = config.NAME
kwargs['version'] = str(config.VERSION)
kwargs["name"] = config.NAME
kwargs["version"] = str(config.VERSION)
if os.path.isfile(path):
return template.get_text_from_path(path, **kwargs)

Expand Down
Loading

0 comments on commit c1975bc

Please sign in to comment.