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

Add function get_value to FSMContext #1431

Open
wrrrzr opened this issue Mar 2, 2024 · 1 comment · May be fixed by #1432
Open

Add function get_value to FSMContext #1431

wrrrzr opened this issue Mar 2, 2024 · 1 comment · May be fixed by #1432
Labels
enhancement Make it better! good first issue A good place to start contributing to this project without going too deep.

Comments

@wrrrzr
Copy link

wrrrzr commented Mar 2, 2024

aiogram version

3.x

Problem

In a situation where you only need to take one value in FSMContext handler, you need to write 2 lines of code to take value

Possible solution

Add a get_value function for FSMContext that takes value by key

Alternatives

No response

Code example

# before
data = await state.get_data()
name = data["name"]

# after
name = await state.get_value("name")

Additional information

No response

@wrrrzr wrrrzr added the enhancement Make it better! label Mar 2, 2024
@JrooTJunior JrooTJunior added the good first issue A good place to start contributing to this project without going too deep. label Mar 3, 2024
@JrooTJunior JrooTJunior linked a pull request Mar 6, 2024 that will close this issue
5 tasks
@infikot
Copy link

infikot commented Apr 14, 2024

# before
data = await state.get_data()
name = data["name"]

# after
name = await state.get_value("name")

# i think
name = await state.get_data()["name"] 

wouldn't that work? :3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Make it better! good first issue A good place to start contributing to this project without going too deep.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants