Refactor and update structure #20
Reference in New Issue
Block a user
Delete Branch "16-refactoring-e-sanity-check"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Update agents and models, reorganize extraction functions, and enhance import management. Improve documentation, type checks, and README. Refactor architecture by relocating core classes and updating import paths for better maintainability.
Pull Request Overview
This PR implements a comprehensive refactoring to improve code structure, enhance type safety, and update the architecture. The changes reorganize core classes, update import paths, and establish a cleaner separation of concerns between agents, base classes, utilities, and API wrappers.
Key changes:
Reviewed Changes
Copilot reviewed 37 out of 39 changed files in this pull request and generated 4 comments.
Show a summary per file
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
The asset_id parameter lacks a default value, which is inconsistent with the previous API design and could break existing code that relied on the default 'BTC' value.
@@ -21,22 +22,20 @@ SUBREDDITS = []Calling .list() on post.comments may load all comments into memory. Consider iterating directly over post.comments to avoid potential memory issues with large comment threads.
@@ -48,3 +49,3 @@"""log_info(f"{inspect.getsource(func).strip()} {inspect.getclosurevars(func).nonlocals}")return self.__try_call(func, try_all=False).popitem()[1]The variable 'error' is initialized but may be used uninitialized if no exception occurs in the while loop before the final raise statement.
@@ -101,0 +88,4 @@if not try_all:log_info(f"try_call {wrapper_name}")for try_count in range(1, self.retry_per_wrapper + 1):The variable 'error' is initialized but may be used uninitialized if no exceptions occur in the for loop before checking if results is empty.
Pull Request Overview
Copilot reviewed 37 out of 39 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@@ -48,3 +49,3 @@"""log_info(f"{inspect.getsource(func).strip()} {inspect.getclosurevars(func).nonlocals}")return self.__try_call(func, try_all=False).popitem()[1][nitpick] The variable 'error' is initialized but may not be used if no exceptions occur in the loop. Consider initializing it only when needed or using a more descriptive default value.
Pull Request Overview
Copilot reviewed 37 out of 39 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@@ -0,0 +87,4 @@raise ValueError(f"Modello non supportato: {self}")def get_agent(self, instructions: str, name: str = "", output_schema: type[BaseModel] | None = None, tools: list[Toolkit] | None = None) -> Agent:"""Using mutable default argument 'tools: list[Toolkit] = []' can lead to unexpected behavior. Use 'tools: list[Toolkit] | None = None' and handle None inside the method.
@@ -0,0 +1,83 @@from datetime import datetimeThe docstring incorrectly states 'timestamp in millisecondi' but the method accepts both milliseconds and seconds. Also, the Args section mentions 'timestamp' parameter which doesn't exist - should document 'timestamp_ms' and 'timestamp_s' parameters.
@@ -1,28 +1,31 @@import osThe docstring states the default currency is 'USD' but then mentions it gets changed to 'USDT'. This is confusing - the documentation should clearly explain that USD gets automatically converted to USDT for Binance compatibility.
Pull Request Overview
Copilot reviewed 40 out of 42 changed files in this pull request and generated 5 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@@ -0,0 +53,4 @@@staticmethoddef availables() -> list['AppModels']:"""The nested list comprehensions and multiple iterations over AppModels could be optimized by creating a set of available models first, then filtering AppModels in a single pass.
@@ -0,0 +30,4 @@"""Imposta il timestamp a partire da millisecondi o secondi.IL timestamp viene salvato come stringa formattata 'YYYY-MM-DD HH:MM'.Args:Corrected spelling of 'IL' to 'Il'.
@@ -46,31 +57,22 @@ class BinanceWrapper(BaseWrapper):def get_product(self, asset_id: str) -> ProductInfo:symbol = self.__format_symbol(asset_id)The automatic conversion from 'USD' to 'USDT' by appending 'T' is fragile and may not work correctly for other currencies. Consider using a proper mapping dictionary for currency conversions.
Using locals() to access 'error' variable is unreliable and may not contain the expected value. The variable should be properly tracked in the exception handling flow.
The hour arithmetic can cause issues when the current hour is 0 or 1, as it would result in negative hours. Use timedelta for proper date arithmetic instead.