Skip to content

Commit

Permalink
move from parse_obj to model_validate
Browse files Browse the repository at this point in the history
  • Loading branch information
billbsing committed Mar 5, 2024
1 parent fe580ec commit 12a196c
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion convex_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
class API:

def __init__(self, url: str):
self._url = url
self._url = str(url)
self._registry = Registry(self)

def create_account(self, key_pair: KeyPair, sequence_retry_count: int = 20) -> Account:
Expand Down
2 changes: 1 addition & 1 deletion convex_api/tool/command/account_balance_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def create_parser(self, sub_parser: SubParsersAction):
return parser

def execute(self, args: Namespace, output: Output):
typed_args = AccountBalanceArgs.parse_obj(vars(args))
typed_args = AccountBalanceArgs.model_validate(vars(args))
convex = self.load_convex(typed_args.url)
info = self.resolve_to_name_address(typed_args.name_address, output)
if not info:
Expand Down
2 changes: 1 addition & 1 deletion convex_api/tool/command/account_create_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def create_parser(self, sub_parser: SubParsersAction):
return parser

def execute(self, args: Namespace, output: Output):
typed_args = AccountCreateArgs.parse_obj(vars(args))
typed_args = AccountCreateArgs.model_validate(vars(args))
convex = self.load_convex(typed_args.url)

key_pair = self.import_key_pair(typed_args)
Expand Down
2 changes: 1 addition & 1 deletion convex_api/tool/command/account_fund_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def create_parser(self, sub_parser: SubParsersAction):
return parser

def execute(self, args: Namespace, output: Output):
typed_args = AccountFundArgs.parse_obj(vars(args))
typed_args = AccountFundArgs.model_validate(vars(args))
convex = self.load_convex(typed_args.url)

account = self.load_account(typed_args, typed_args.name_address, output)
Expand Down
2 changes: 1 addition & 1 deletion convex_api/tool/command/account_info_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def create_parser(self, sub_parser: SubParsersAction):
return parser

def execute(self, args: Namespace, output: Output):
typed_args = AccountInfoArgs.parse_obj(vars(args))
typed_args = AccountInfoArgs.model_validate(vars(args))
convex = self.load_convex(typed_args.url)
info = self.resolve_to_name_address(typed_args.name_address, output)
if not info:
Expand Down
6 changes: 3 additions & 3 deletions convex_api/tool/command/account_name_register_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
class AccountNameRegisterArgs(BaseArgs):
command: Literal['account']
account_command: Literal['register']
name_address: str
name_address: str | int
name: str
address: str
address: str | int


class AccountNameRegisterCommand(CommandBase):
Expand Down Expand Up @@ -59,7 +59,7 @@ def create_parser(self, sub_parser: SubParsersAction):
return parser

def execute(self, args: Namespace, output: Output):
typed_args = AccountNameRegisterArgs.parse_obj(vars(args))
typed_args = AccountNameRegisterArgs.model_validate(vars(args))
convex = self.load_convex(typed_args.url)

account = self.load_account(typed_args, typed_args.name_address, output)
Expand Down
2 changes: 1 addition & 1 deletion convex_api/tool/command/account_name_resolve_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def create_parser(self, sub_parser: SubParsersAction):
return parser

def execute(self, args: Namespace, output: Output):
typed_args = AccountNameResolveArgs.parse_obj(vars(args))
typed_args = AccountNameResolveArgs.model_validate(vars(args))
convex = self.load_convex(typed_args.url)
address = convex.resolve_account_name(typed_args.name)
if address:
Expand Down
2 changes: 1 addition & 1 deletion convex_api/tool/command/account_topup_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def create_parser(self, sub_parser: SubParsersAction):
return parser

def execute(self, args: Namespace, output: Output):
typed_args = AccountTopupArgs.parse_obj(vars(args))
typed_args = AccountTopupArgs.model_validate(vars(args))
convex = self.load_convex(typed_args.url)
account = self.load_account(typed_args, typed_args.name_address, output)
if not account:
Expand Down
13 changes: 13 additions & 0 deletions tests/intergration/tool/test_account_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def test_account_balance_command(convex_url: str, test_account: Account):
args.account_command = 'balance'
args.url = convex_url
args.name_address = test_account.address
args.keyfile = None
args.keytext = None
args.password = None
args.keywords = None

command = AccountBalanceCommand()
output = Output()
Expand All @@ -71,6 +75,10 @@ def test_account_info_command(convex_url: str, test_account: Account):
args.account_command = 'info'
args.url = convex_url
args.name_address = test_account.address
args.keyfile = None
args.keytext = None
args.password = None
args.keywords = None

command = AccountInfoCommand()
output = Output()
Expand Down Expand Up @@ -102,6 +110,11 @@ def test_account_name_resolve_command(convex_url: str, test_account: Account):
args.account_command = 'resolve'
args.url = convex_url
args.name = test_account.name
args.keyfile = None
args.keytext = None
args.password = None
args.keywords = None


command = AccountNameResolveCommand()
output = Output()
Expand Down
4 changes: 4 additions & 0 deletions tests/intergration/tool/test_query_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def test_query_command(convex_url: str):
args.url = convex_url
args.query = '(address *registry*)'
args.name_address = None
args.keyfile = None
args.keytext = None
args.password = None
args.keywords = None

command = QueryCommand()
output = Output()
Expand Down

0 comments on commit 12a196c

Please sign in to comment.