Skip to content

PYTHON-5115 Type validation errors should include the invalid type name #2085

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

Merged
merged 8 commits into from
Jan 31, 2025
Merged

PYTHON-5115 Type validation errors should include the invalid type name #2085

merged 8 commits into from
Jan 31, 2025

Conversation

tejaschauhan36912
Copy link
Contributor

  • Enhanced error message with more details for better debugging experience.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the changes in this file (and some other asynchronous files) aren't reflected in sync, did you run prepre-commit run --all-files before committing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I did but not getting any changes in sync files.

$ pre-commit run --all-files
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check toml...............................................................Passed
check yaml...............................................................Passed
debug statements (python)................................................Passed
fix end of files.........................................................Passed
forbid new submodules................................(no files to check)Skipped
trim trailing whitespace.................................................Passed
synchro..................................................................Passed
ruff.....................................................................Passed
ruff-format..............................................................Passed
blacken-docs.............................................................Passed
rst code is two backticks............................................Passed
rst directives end with two colons.......................................Passed
rst inline code next to normal text..................................Passed
rstcheck.................................................................Passed
Validate GitHub Workflows................................................Passed
Validate GitHub Actions..............................(no files to check)Skipped
Validate Dependabot Config (v2)..........................................Passed
codespell................................................................Passed
executable-shell.........................................................Passed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have invited you to access my forked repo, clone it, check out the detailed-error-msg branch, run pre-commit in your environment and if it works then push the changes here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @sleepyStick!
Please help to merge this PR.
Does the tools\synchro.py migrate error message changes?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry just seeing this, let me try this now :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I just ran pre-commit on my local copy of your branch and synchro looked like this (which is what i expected)

synchro..................................................................Failed
- hook id: synchro
- files were modified by this hook

just pushed those changes :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry just seeing this, let me try this now :)

Hey, thanks for listening, you are a gem!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just ran pre-commit on my local copy of your branch and synchro looked like this (which is what i expected)

synchro..................................................................Failed
- hook id: synchro
- files were modified by this hook

just pushed those changes :)

Oh, then something is wrong with my setup.

sleepyStick
sleepyStick previously approved these changes Jan 29, 2025
Copy link
Contributor

@sleepyStick sleepyStick left a comment

Choose a reason for hiding this comment

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

the long awaited LGTM has arrived! thanks for doing this!

@tejaschauhan36912
Copy link
Contributor Author

@sleepyStick please merge this PR if we don't have any changes to add.

Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

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

@sleepyStick do you mind opening a Jira ticket to describe this change and linking it in the PR title + merge commit?

@@ -161,7 +161,7 @@ def _password_digest(username: str, password: str) -> str:
if len(password) == 0:
raise ValueError("password can't be empty")
if not isinstance(username, str):
raise TypeError("username must be an instance of str")
raise TypeError(f"username must be an instance of str, not {type(username)}.")
Copy link
Member

Choose a reason for hiding this comment

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

It is customary to omit the period in these error messages. Do you mind changing these from not {type(<>)}." to not {type(<>)}"?

Copy link
Member

Choose a reason for hiding this comment

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

Actually is seems there are examples of both in our codebase so either way is fine with me though I still have a slight preference for omitting it. @sleepyStick I'll defer to your opinion.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I like omitting it as well, lemme clean it up and then I'll merge it :)

@sleepyStick
Copy link
Contributor

@sleepyStick please merge this PR if we don't have any changes to add.

Sorry, I kinda thought you could merge and I wanted you to have the honors!

@sleepyStick
Copy link
Contributor

@sleepyStick do you mind opening a Jira ticket to describe this change and linking it in the PR title + merge commit?

created PYTHON-5115

@sleepyStick sleepyStick changed the title Detailed error message for better debugging PYTHON-5115 Type validation errors should include the invalid type name Jan 30, 2025
Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @tejaschauhan36912 and @sleepyStick!

@sleepyStick sleepyStick merged commit 44d1d40 into mongodb:master Jan 31, 2025
27 of 28 checks passed
@tejaschauhan36912 tejaschauhan36912 deleted the detailed-error-msg branch February 4, 2025 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants