Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: make gender input case-insensitive and clean up pre-commit config #4855

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

fengxiaohu
Copy link

Summary

This PR improves the gender input handling in examples/conversationbot.py by using a case-insensitive regex.
It also corrects a pre-commit hook configuration issue in .pre-commit-config.yaml (invalid stages field in isort).

Changes

  • Made gender selection case-insensitive using (?i) regex.
  • Updated .pre-commit-config.yaml to fix isort hook crash due to invalid stages.
  • Verified pre-commit hook passes for ruff, black, flake8, isort, and mypy.

Check-list

  • Created/adapted unit test or verified functionality manually
  • Documented behavior change in example
  • All pre-commit hooks pass (pre-commit run -a)
  • Added .. versionchanged:: NEXT.VERSION to example function (optional)
  • Added myself to AUTHORS.rst (optional)
  • No breaking changes or violations of stability policy

Copy link
Member

@harshil21 harshil21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@@ -145,7 +145,7 @@ def main() -> None:
conv_handler = ConversationHandler(
entry_points=[CommandHandler("start", start)],
states={
GENDER: [MessageHandler(filters.Regex("^(Boy|Girl|Other)$"), gender)],
GENDER: [MessageHandler(filters.Regex("(?i)^(Boy|Girl|Other)$"), gender)],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment saying that this is a case-insensitive

@harshil21 harshil21 added the ⚙️ examples affected functionality: examples label Jul 7, 2025
@harshil21 harshil21 linked an issue Jul 7, 2025 that may be closed by this pull request
@fengxiaohu
Copy link
Author

can not pass CI.
I guess change the .pre-commit-config.yaml.
however when i use the normal .pre-commit-config.yaml. I can not pass the precommit
run pre-commit run -a

output looks like

An error has occurred: InvalidManifestError: ==> File /Users/xiaohufeng/.cache/pre-commit/repooacu36pw/.pre-commit-hooks.yaml ==> At Hook(id='isort') ==> At key: stages ==> At index 0 =====> Expected one of commit, commit-msg, manual, merge-commit, post-checkout, post-commit, post-merge, post-rewrite, prepare-commit-msg, push but got: 'pre-commit' Check the log at /Users/xiaohufeng/.cache/pre-commit/pre-commit.log

@harshil21
Copy link
Member

I'm not sure what could be causing that. Maybe run: pre-commit uninstall, pre-commit clean, and then reinstall with pre-commit install. If that doesn't work, just commit without running pre-commit, e.g. git commit -n -a -m "commit msg".

@fengxiaohu fengxiaohu closed this Jul 8, 2025
@fengxiaohu fengxiaohu reopened this Jul 8, 2025
Copy link
Member

@Bibo-Joshi Bibo-Joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly also add a new file changes/unreleased/4855.8hCFRFMeMaRWpBEYaxrTMq.toml with the following content:

other= "Make Gender Input Case-Insensitive in ``conversationbot.py``"
[[pull_requests]]
uid = "4855"
author_uid = "fengxiaohu"
closes_threads = ["4846"]

@@ -80,4 +80,4 @@ repos:
name: isort
args:
- --diff
- --check
- --check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add an empty newline at the end of the file to completely revert your changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙️ examples affected functionality: examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

case-insensitive in conversationbot.py bot demo
3 participants