Skip to content

Commit ad46661

Browse files
committed
Code cleanups before release.
1 parent 9b370c1 commit ad46661

File tree

15 files changed

+27
-29
lines changed

15 files changed

+27
-29
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ and database names if you want to install multiple bots for multiple Discord gro
261261
> If you need to rename a node, just launch `install.cmd` again with the --node parameter and give it the new name.
262262
> You will then get a list of existing nodes and will be asked to either add a new node or rename an existing one.
263263
> Select rename an `existing` one and select the node to be renamed.<br>
264-
> This might be necessary, if your hostname changes or you move a bot from one PC to another.
264+
> This might be necessary, if your hostname changes, or you move a bot from one PC to another.
265265
266266
### Desanitization
267267
DCSServerBot desanitizes your MissionScripting environment. That means it changes entries in Scripts\MissionScripting.lua
@@ -718,7 +718,7 @@ In these cases, you can run the `repair.cmd` script in the DCSServerBot installa
718718
---
719719

720720
## Backup and Restore
721-
The platform allows you to backup and restore your database, server configurations, or bot settings.
721+
The platform allows you to back up and restore your database, server configurations, or bot settings.
722722
The backup and restore functionality are accessible in the Backup [service](./services/backup/README.md)
723723
and [plugin](./plugins/backup/README.md).
724724

core/data/const.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ class PortType(Enum):
5656
class Port:
5757

5858
def __init__(self, port: int, typ: PortType, *, public: bool = False):
59-
self.port = port
60-
self.typ = typ
61-
self.public = public
59+
self.port: int = port
60+
self.typ: PortType = typ
61+
self.public: bool = public
6262

6363
def __repr__(self):
6464
return f'{self.port}/{self.typ.value}'
@@ -82,5 +82,5 @@ def __eq__(self, other):
8282
return self.port == other
8383
return False
8484

85-
def type(self):
85+
def type(self) -> PortType:
8686
return self.typ

core/data/impl/nodeimpl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@
3333
from psycopg.errors import UndefinedTable, InFailedSqlTransaction, ConnectionTimeout, UniqueViolation
3434
from psycopg.types.json import Json
3535
from psycopg_pool import ConnectionPool, AsyncConnectionPool
36-
from typing import Awaitable, Callable, Any, cast
36+
from typing import Awaitable, Callable, Any
3737
from typing_extensions import override
3838
from urllib.parse import urlparse, quote
3939
from version import __version__
4040
from zoneinfo import ZoneInfo
4141

4242
from core.autoexec import Autoexec
43-
from core.data.dataobject import DataObjectFactory, DataObject
43+
from core.data.dataobject import DataObjectFactory
4444
from core.data.node import Node, UploadStatus, SortOrder, FatalException
4545
from core.data.instance import Instance
4646
from core.data.impl.instanceimpl import InstanceImpl
4747
from core.data.server import Server
4848
from core.data.impl.serverimpl import ServerImpl
4949
from core.services.registry import ServiceRegistry
50-
from core.utils.helper import SettingsDict, YAMLError, cache_with_expiration
50+
from core.utils.helper import YAMLError, cache_with_expiration
5151

5252
# ruamel YAML support
5353
from ruamel.yaml import YAML

core/pubsub.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import zlib
33

44
from contextlib import suppress
5-
from psycopg import sql, Connection, OperationalError, AsyncConnection
5+
from psycopg import sql, Connection, OperationalError, AsyncConnection, InternalError
66
from typing import Callable
77

88
from core.data.impl.nodeimpl import NodeImpl

core/utils/helper.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,14 +499,14 @@ def get_cache_key(*args, **kwargs):
499499
# Convert unhashable types to hashable forms
500500
hashable_args = []
501501
for k, v in bound_args.arguments.items():
502-
if k not in ["interaction"]: # Removed "self" from exclusion list
502+
if k not in ["interaction"]: # Removed "self" from the exclusion list
503503
# For the self-parameter, use its id as part of the key
504504
if k == "self":
505505
hashable_args.append(id(v))
506506
# if we have a .name element, use this as key instead
507507
elif hasattr(v, "name") and not isinstance(v, (str, bytes)):
508508
hashable_args.append(("name", getattr(v, "name", None)))
509-
# Convert lists to tuples, and handle nested lists
509+
# Convert lists to tuples and handle nested lists
510510
elif isinstance(v, list):
511511
hashable_args.append(tuple(tuple(x) if isinstance(x, list) else x for x in v))
512512
else:
@@ -608,7 +608,7 @@ async def _get_lock(cache_key) -> asyncio.Lock:
608608
# Fast path
609609
lock = locks.get(cache_key)
610610
if lock is None:
611-
# Create lazily; small race is fine (we only need mutual exclusion, not singletons)
611+
# Create lazily; a small race is fine (we only need mutual exclusion, not singletons)
612612
lock = asyncio.Lock()
613613
locks[cache_key] = lock
614614
return lock
@@ -958,7 +958,7 @@ def deep_merge(dict1, dict2):
958958

959959

960960
def hash_password(password: str) -> str:
961-
# Generate an 11 character alphanumeric string
961+
# Generate an 11-character alphanumeric string
962962
key = ''.join(secrets.choice(string.ascii_letters + string.digits) for _ in range(11))
963963

964964
# Create a 32-byte-digest using the "Blake2b" hash algorithm
@@ -1115,7 +1115,7 @@ def process_pattern(_next, data, search, depth, debug, **kwargs):
11151115
class YAMLError(Exception):
11161116
"""
11171117
1118-
The `YAMLError` class is an exception class that is raised when there is an error encountered while parsing or scanning a YAML file.
1118+
The `YAMLError` class is an exception class raised when there is an error encountered while parsing or scanning a YAML file.
11191119
11201120
**Methods:**
11211121

extensions/lardoon/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ MyNode:
2929
tacviewExportPath: 'G:\My Drive\Tacview Files' # Alternative drive for tacview files (default: auto-detect from Tacview)
3030
```
3131
Remember to add some kind of security before exposing services like that to the outside world, with, for instance,
32-
an nginx reverse proxy.</br>
32+
a nginx reverse proxy.</br>
3333
If you plan to build Lardoon on your own, I'd recommend the fork of [Team LimaKilo](https://github.com/team-limakilo/lardoon).
3434
3535
> [!IMPORTANT]

extensions/tacview/extension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ async def uninstall(self) -> bool:
436436
try:
437437
os.rmdir(dir_y) # only removes empty directories
438438
except OSError:
439-
pass # directory not empty
439+
pass # the directory is not empty
440440
# rewrite / remove the export.lua file
441441
if os.path.exists(export_file):
442442
async with aiofiles.open(export_file, mode='r', encoding='utf-8') as infile:

plugins/creditsystem/listener.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,6 @@ async def donate(self, server: Server, player: CreditPlayer, params: list[str]):
310310

311311
@chat_command(name="tip", help=_("Tip a GCI with points"))
312312
async def tip(self, server: Server, player: CreditPlayer, params: list[str]):
313-
player: CreditPlayer = cast(CreditPlayer, player)
314-
315313
if not params:
316314
await player.sendChatMessage(_("Usage: {prefix}{command} points [gci_number]").format(
317315
prefix=self.prefix, command=self.tip.name))

plugins/help/commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,10 @@ async def generate_commands_doc(self, interaction: discord.Interaction, fmt: Lit
302302
role: Literal['Admin', 'DCS Admin', 'DCS'] | None = None,
303303
channel: discord.TextChannel | None = None):
304304
class DocModal(Modal):
305+
# noinspection PyTypeChecker
305306
header = TextInput(label="Header", default=_("## DCSServerBot Commands"), style=TextStyle.short,
306307
required=True)
308+
# noinspection PyTypeChecker
307309
intro = TextInput(label="Intro", style=TextStyle.long, required=True)
308310

309311
def __init__(derived, role: str | None):

plugins/scheduler/commands.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import asyncio
2-
from distutils.dep_util import newer
3-
42
import discord
53
import math
64
import os

0 commit comments

Comments
 (0)