adaptix icon indicating copy to clipboard operation
adaptix copied to clipboard

Add `else` clause to catch a case where `ValidationError` does not happen in pydantic example

Open sobolevn opened this issue 10 months ago • 5 comments

sobolevn avatar Feb 26 '25 09:02 sobolevn

This does not seem related:

 lint: commands[3]> python scripts/astpath_lint.py src/ scripts/ examples/ benchmarks/benchmarks/pybench/ docs/examples/ docs/custom_ext/ tests/
no issues found
  lint: FAIL code 1 (42.57=setup[6.18]+cmd[0.07,20.52,14.12,1.68] seconds)
  evaluation failed :( (42.76 seconds)
error: Recipe `lint` failed on line 22 with exit code 1
Error: Process completed with exit code 1.

sobolevn avatar Feb 26 '25 20:02 sobolevn

@sobolevn Hello! Thank you for your contribution! The main purpose of these examples is demonstration of code behavior, I think that such additions make readability worse.

If you are interesting to exclude possible errors with exception skipped, there are idea to use pytest.raises() context manager inside examples. I have some doubts about this way since documentation examples start look like tests but pytest primitives should be clear to any reader.

zhPavel avatar Mar 03 '25 19:03 zhPavel

I think that such additions make readability worse.

Current code says: ignore ValidationError if it happens. My version says: ValidationError must happen here.

sobolevn avatar Mar 03 '25 23:03 sobolevn

Anyways, I don't really have a strong opinion about it, so feel free to close :)

sobolevn avatar Mar 03 '25 23:03 sobolevn