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

Make stream_settings optional in Inbound model #35

Merged
merged 6 commits into from
Nov 19, 2024
Merged

Conversation

F1bos
Copy link
Contributor

@F1bos F1bos commented Nov 12, 2024

Sometimes stream_settings can be an empty string, for example if inbound is socks proxy. Right now methods related to inbound will fail if it's socks inbound. This pull request fixes it.

Code to reproduce:

from py3xui import AsyncApi
import asyncio

async def main():
    api = AsyncApi.from_env()

    await api.login()

    inbounds = await api.inbound.get_list()
    print(inbounds)

asyncio.run(main())

Create a socks inbound and try running this code, it will fail with this exception:

pydantic_core._pydantic_core.ValidationError: 1 validation error for Inbound
streamSettings
  Input should be a valid dictionary or instance of StreamSettings [type=model_type, input_value='', input_type=str]
    For further information visit https://errors.pydantic.dev/2.9/v/model_type

@iwatkot iwatkot self-assigned this Nov 16, 2024
@iwatkot
Copy link
Owner

iwatkot commented Nov 16, 2024

@F1bos, hello!

Thank you for the PR!

Automatic checks are failing:

py3xui/inbound/inbound.py:106: error: Item "str" of "StreamSettings | str" has no attribute "model_dump_json"  [union-attr]

Please update the corresponding method, otherwise it will fail with AttributeError.

Sincerely

@iwatkot iwatkot added enhancement New feature or request invalid This doesn't seem right labels Nov 16, 2024
@F1bos
Copy link
Contributor Author

F1bos commented Nov 19, 2024

Hi, @iwatkot
Should be fixed.

39 passed in 0.56s

@iwatkot
Copy link
Owner

iwatkot commented Nov 19, 2024

@F1bos, please fix the pylint errors:

py3xui/inbound/inbound.py:62:0: C0301: Line too long (114/100) (line-too-long)
py3xui/inbound/inbound.py:114:52: E1101: Instance of 'FieldInfo' has no 'model_dump_json' member (no-member)

And I'm merging it.

Thank you
Sincerely

@F1bos
Copy link
Contributor Author

F1bos commented Nov 19, 2024

@iwatkot
Done.


Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

39 passed in 0.58s

@F1bos
Copy link
Contributor Author

F1bos commented Nov 19, 2024

@iwatkot fixed type comment 🥶

@iwatkot iwatkot merged commit 0efbf74 into iwatkot:main Nov 19, 2024
1 of 2 checks passed
@iwatkot iwatkot removed the invalid This doesn't seem right label Nov 19, 2024
@iwatkot
Copy link
Owner

iwatkot commented Nov 19, 2024

@F1bos, thanks for contributing!

The new release is ready.

Sincerely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants