radish-bdd / radish

Behavior Driven Development tooling for Python. The root from red to green.
https://radish-bdd.github.io
MIT License
180 stars 49 forks source link

Add and Fix docs for split_unescape #460

Closed ajratnam closed 11 months ago

ajratnam commented 11 months ago

split_unescape function didn't have its docstring completly written. The example in the doc had a mistake, raw strings also cannot end with a single backslash.

fliiiix commented 11 months ago

Do you have any idea why

>>> split_unescape(r'foo\|bar', '|')
['foo|bar']

leads to radish/utils.py:190: DeprecationWarning: invalid escape sequence |

because i think that should not happen because we us a raw string

codecov[bot] commented 11 months ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (a515e15) 87.26% compared to head (46580cc) 87.26%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #460 +/- ## ======================================= Coverage 87.26% 87.26% ======================================= Files 39 39 Lines 2380 2380 ======================================= Hits 2077 2077 Misses 303 303 ``` | [Flag](https://app.codecov.io/gh/radish-bdd/radish/pull/460/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=radish-bdd) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/radish-bdd/radish/pull/460/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=radish-bdd) | `87.26% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=radish-bdd#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/radish-bdd/radish/pull/460?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=radish-bdd) | Coverage Δ | | |---|---|---| | [radish/utils.py](https://app.codecov.io/gh/radish-bdd/radish/pull/460?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=radish-bdd#diff-cmFkaXNoL3V0aWxzLnB5) | `69.38% <ø> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ajratnam commented 11 months ago

I think that's because you normally use r strings to unescape any escaped sequence but in our case \| isn't an escape sequence so nothing is being escaped

>>> r'\|' == '\|'
True
>>> print(r'\|')
\|
>>> print('\|')
\|

imo, the fix for it would be using normal string with \\ or I think it maybe some issue with flake8 also

ajratnam commented 11 months ago

Yeah, I changed it to that, and my linter doesn't show me that error anymore. I think this fixes #443

fliiiix commented 11 months ago

thanks again merged and release with 0.17.0