Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruff20241218 fixing all but one ruff lint #693

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
---
name: Lint
on: [push, pull_request] # yamllint disable-line rule:truthy
on: [push, pull_request]
jobs:
yaml-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- run: pip install yamllint
- run: yamllint .
flake8-lint:
runs-on: ubuntu-latest
steps:
Expand Down
35 changes: 0 additions & 35 deletions new_features_examples/microstructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,41 +418,6 @@ def __init__(self, api_key: str):
exchange_manager = ExchangeManager()
self.exchange = exchange_manager.get_primary_exchange()

def calculate_tick_metrics(
self, ticks: List[Dict]
) -> Dict[str, float]:
df = pd.DataFrame(ticks)
df["price"] = pd.to_numeric(df["price"])
df["volume"] = pd.to_numeric(df["amount"])

# Calculate key metrics
metrics = {}

# Volume-weighted average price (VWAP)
metrics["vwap"] = (df["price"] * df["volume"]).sum() / df[
"volume"
].sum()

# Price momentum
metrics["price_momentum"] = df["price"].diff().mean()

# Volume profile
metrics["volume_mean"] = df["volume"].mean()
metrics["volume_std"] = df["volume"].std()

# Trade intensity
time_diff = (
df["timestamp"].max() - df["timestamp"].min()
) / 1000 # Convert to seconds
metrics["trade_intensity"] = (
len(df) / time_diff if time_diff > 0 else 0
)

# Microstructure indicators
metrics["kyle_lambda"] = self.calculate_kyle_lambda(df)
metrics["roll_spread"] = self.calculate_roll_spread(df)

return metrics

def calculate_kyle_lambda(self, df: pd.DataFrame) -> float:
"""Calculate Kyle's Lambda (price impact coefficient)"""
Expand Down
3 changes: 1 addition & 2 deletions new_features_examples/multi_tool_usage_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@
history: List[Dict[str, Any]] = field(default_factory=list)


hints = get_type_hints(func)

hints = get_type_hints(func) # noqa: F821

Check failure

Code scanning / Pyre

Unbound name Error

Unbound name [10]: Name func is used but not defined in the current scope.

class ToolAgent:
def __init__(
Expand Down
2 changes: 1 addition & 1 deletion swarms/tools/py_func_to_openai_func_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from pydantic import BaseModel, Field
from pydantic.version import VERSION as PYDANTIC_VERSION
from typing_extensions import Annotated, Literal, get_args, get_origin
from typing_extensions import Annotated, Literal, get_origin

T = TypeVar("T")

Expand Down
12 changes: 8 additions & 4 deletions tests/agent_evals/auto_test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
import swarms

return swarms.__version__
except:
except ImportError:
return "Unknown"

def _get_gpu_info(self) -> Tuple[bool, Optional[str]]:
Expand All @@ -109,9 +109,12 @@
cuda_available = torch.cuda.is_available()
if cuda_available:
gpu_info = torch.cuda.get_device_name(0)
return cuda_available, gpu_info
return cuda_available, gpu_info

Check failure

Code scanning / Pyre

Uninitialized local Error test

Uninitialized local [61]: Local variable gpu\_info is undefined, or not always defined.
return False, None
except:
except ImportError:
return False, None
except Exception as e:
logger.error(f"Error getting GPU info: {str(e)}")
return False, None

def _get_system_info(self) -> SwarmSystemInfo:
Expand Down Expand Up @@ -207,7 +210,8 @@
for dist in pkg_resources.working_set:
deps.append(f"- {dist.key} {dist.version}")
return "\n".join(deps)
except:
except Exception as e:
logger.error(f"Error fetching dependency information: {str(e)}")
return "Unable to fetch dependency information"

# First, add this method to your SwarmsIssueReporter class
Expand Down
Loading