alpacahq / alpacahq/alpaca-py

[Bug]: DeprecationWarning: websockets.legacy is deprecated

Open
#561 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
1.5k
Forks
398
Avg merge
1d 16h
Merged PRs (30d)
6

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Current Behavior

A recent version of the package `websockets` reports a deprecation warning when websockets.legacy is used:

> ../../../Library/Caches/pypoetry/virtualenvs/stocktrader-BHJNSc0O-py3.11/lib/python3.11/site-packages/websockets/legacy/__init__.py:6
> /Users/myuser/Library/Caches/pypoetry/virtualenvs/stocktrader-BHJNSc0O-py3.11/lib/python3.11/site-packages/websockets/legacy/__init__.py:6: DeprecationWarning: websockets.legacy is deprecated; see https://websockets.readthedocs.io/en/stable/howto/upgrade.html for upgrade instructions
> warnings.warn( # deprecated in 14.0 - 2024-11-09
>
> -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

It appears websockets.legacy is being used in [stream](https://github.com/alpacahq/alpaca-py/blob/7fa0a94053a2c91168aa7df91b3f916879fcc290/alpaca/trading/stream.py#L9) and [websocket](https://github.com/alpacahq/alpaca-py/blob/7fa0a94053a2c91168aa7df91b3f916879fcc290/alpaca/data/live/websocket.py#L10)

### Expected Behavior

We should not be using deprecated packages

### SDK Version I encountered this issue in

0.38.0

### Steps To Reproduce

```markdown
- Use the latest version of websockets, i.e. ^14.2
- Run code that uses Alpaca's TradingStream
```

### Filled out the Steps to Reproduce section?

- [x] I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.