From e4a10248df41c612e1b76298fc8b14d6521d668a Mon Sep 17 00:00:00 2001 From: Bedram Tamang Date: Fri, 25 Sep 2026 13:51:36 -0700 Subject: [PATCH] fix(orm): resolve basedpyright errors in migration and make commands handle() now declares -> int and returns 0 explicitly (cleo already mapped None to 0), and resolve_migration_path() returns str as annotated. Co-Authored-By: Claude Opus 5.5 --- .../masoniteorm/commands/DBMigrateCommand.py | 7 ++++--- .../fastapi_startkit/masoniteorm/commands/DBSeedCommand.py | 5 +++-- .../masoniteorm/commands/MakeMigrationCommand.py | 3 ++- .../masoniteorm/commands/MakeModelCommand.py | 6 ++++-- .../masoniteorm/commands/MakeSeedCommand.py | 6 ++++-- .../masoniteorm/commands/MigrateFreshCommand.py | 7 ++++--- .../masoniteorm/commands/MigrateRefreshCommand.py | 7 ++++--- .../masoniteorm/commands/MigrateResetCommand.py | 7 ++++--- .../masoniteorm/commands/MigrateRollbackCommand.py | 7 ++++--- .../masoniteorm/commands/MigrateStatusCommand.py | 7 ++++--- 10 files changed, 37 insertions(+), 25 deletions(-) diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBMigrateCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBMigrateCommand.py index c443bd81..97226c05 100644 --- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBMigrateCommand.py +++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBMigrateCommand.py @@ -40,10 +40,11 @@ class DBMigrateCommand(Command): ), ] - def handle(self): + def handle(self) -> int: import asyncio - return asyncio.run(self.handle_async()) + asyncio.run(self.handle_async()) + return 0 async def handle_async(self): self.confirm_to_proceed() @@ -72,7 +73,7 @@ def resolve_migration_path(self) -> str: default_directory = config.get("directory") migration_directory = path or default_directory - return self.container.use_base_path(migration_directory) + return str(self.container.use_base_path(migration_directory)) def confirm_to_proceed(self) -> None: # prompt user for confirmation in production diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBSeedCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBSeedCommand.py index 9c616dbb..e13a679a 100644 --- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBSeedCommand.py +++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBSeedCommand.py @@ -40,10 +40,11 @@ class DBSeedCommand(Command): ), ] - def handle(self): + def handle(self) -> int: import asyncio - return asyncio.run(self.handle_async()) + asyncio.run(self.handle_async()) + return 0 async def handle_async(self): from ..seeders import Seeder diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeMigrationCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeMigrationCommand.py index 9f5db9c2..1eba02af 100644 --- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeMigrationCommand.py +++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeMigrationCommand.py @@ -25,7 +25,7 @@ class MakeMigrationCommand(Command): ), ] - def handle(self): + def handle(self) -> int: name = self.argument("name").replace("-", "_") now = datetime.datetime.today() @@ -60,3 +60,4 @@ def handle(self): fp.write(output) self.info(f"Migration file created: {os.path.join(migration_directory, file_name)}") + return 0 diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeModelCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeModelCommand.py index 39c66c5f..a4ea9e9c 100644 --- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeModelCommand.py +++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeModelCommand.py @@ -55,7 +55,7 @@ class MakeModelCommand(Command): ), ] - def handle(self): + def handle(self) -> int: name = self.argument("name") model_directory = self.option("directory") @@ -73,7 +73,7 @@ def handle(self): if os.path.exists(os.path.join(full_directory_path, file_name)): self.line(f'Model "{name}" Already Exists ({full_directory_path}/{file_name})') - return + return 0 os.makedirs(os.path.dirname(os.path.join(full_directory_path)), exist_ok=True) @@ -97,3 +97,5 @@ def handle(self): if self.option("seeder"): directory = self.option("seeders-directory") self.call("seed", f"{self.argument('name')} --directory {directory}") + + return 0 diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeSeedCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeSeedCommand.py index badf3b8d..dc1dc4b4 100644 --- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeSeedCommand.py +++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeSeedCommand.py @@ -21,7 +21,7 @@ class MakeSeedCommand(Command): ), ] - def handle(self): + def handle(self) -> int: # get the contents of a stub file # replace the placeholders of a stub file # output the content to a file location @@ -46,9 +46,11 @@ def handle(self): path_normalized = pathlib.Path(seed_directory) / pathlib.Path(file_name) if os.path.exists(full_path): - return self.line(f"{path_normalized} already exists.") + self.line(f"{path_normalized} already exists.") + return 0 with open(full_path, "w") as fp: fp.write(output) self.info(f"Seed file created: {path_normalized}") + return 0 diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateFreshCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateFreshCommand.py index 8c5e3cb9..f720f056 100644 --- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateFreshCommand.py +++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateFreshCommand.py @@ -44,10 +44,11 @@ class MigrateFreshCommand(Command): ), ] - def handle(self): + def handle(self) -> int: import asyncio - return asyncio.run(self.handle_async()) + asyncio.run(self.handle_async()) + return 0 async def handle_async(self): directory = self.resolve_migration_path() @@ -78,4 +79,4 @@ def resolve_migration_path(self) -> str: default_directory = config.get("directory") migration_directory = path or default_directory - return self.container.use_base_path(migration_directory) + return str(self.container.use_base_path(migration_directory)) diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRefreshCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRefreshCommand.py index 22e5d94d..fcc48d73 100644 --- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRefreshCommand.py +++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRefreshCommand.py @@ -45,10 +45,11 @@ class MigrateRefreshCommand(Command): ), ] - def handle(self): + def handle(self) -> int: import asyncio - return asyncio.run(self.handle_async()) + asyncio.run(self.handle_async()) + return 0 async def handle_async(self): directory = self.resolve_migration_path() @@ -79,4 +80,4 @@ def resolve_migration_path(self) -> str: default_directory = config.get("directory") migration_directory = path or default_directory - return self.container.use_base_path(migration_directory) + return str(self.container.use_base_path(migration_directory)) diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateResetCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateResetCommand.py index 1832aa9b..4bb2d469 100644 --- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateResetCommand.py +++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateResetCommand.py @@ -31,10 +31,11 @@ class MigrateResetCommand(Command): ), ] - def handle(self): + def handle(self) -> int: import asyncio - return asyncio.run(self.handle_async()) + asyncio.run(self.handle_async()) + return 0 async def handle_async(self): directory = self.resolve_migration_path() @@ -54,4 +55,4 @@ def resolve_migration_path(self) -> str: default_directory = config.get("directory") migration_directory = path or default_directory - return self.container.use_base_path(migration_directory) + return str(self.container.use_base_path(migration_directory)) diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRollbackCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRollbackCommand.py index 7eab0728..d907276e 100644 --- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRollbackCommand.py +++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRollbackCommand.py @@ -31,10 +31,11 @@ class MigrateRollbackCommand(Command): ), ] - def handle(self): + def handle(self) -> int: import asyncio - return asyncio.run(self.handle_async()) + asyncio.run(self.handle_async()) + return 0 async def handle_async(self): directory = self.resolve_migration_path() @@ -54,4 +55,4 @@ def resolve_migration_path(self) -> str: default_directory = config.get("directory") migration_directory = path or default_directory - return self.container.use_base_path(migration_directory) + return str(self.container.use_base_path(migration_directory)) diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateStatusCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateStatusCommand.py index 5ac18f86..ba9b15a0 100644 --- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateStatusCommand.py +++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateStatusCommand.py @@ -24,10 +24,11 @@ class MigrateStatusCommand(Command): ), ] - def handle(self): + def handle(self) -> int: import asyncio - return asyncio.run(self.handle_async()) + asyncio.run(self.handle_async()) + return 0 async def handle_async(self): directory = self.resolve_migration_path() @@ -77,4 +78,4 @@ def resolve_migration_path(self) -> str: default_directory = config.get("directory") migration_directory = path or default_directory - return self.container.use_base_path(migration_directory) + return str(self.container.use_base_path(migration_directory))