Fixing typo in cython casting lint, and making it azure friendly
State: closed

@jbrockmendel 

Fixing typo introduced in #23474, when validating the spaces in casts in the cython code.

The original grep command used was:
`grep -r -E --include '*.pyx' --include '*.pxi.in' '> ' pandas/_libs | grep -v '[ ->]> ' `

If I'm not mistaken, the goal of `grep -v '[ ->]> '` was to exclude from the initially caught `> ` the cases where before the greater than we have a space, a hyphen or another greater than. The problem is that the hyphen is understood as a range, like in `[a-z]`, and the regex is excluding other characters, like the star. So, we're exclusing cases like:
```
pandas/_libs/window.pyx:        buf = <float64_t *> arr.data
pandas/_libs/window.pyx:        oldbuf = <float64_t *> bufarr.data
pandas/_libs/window.pyx:            bufarr.data = <char *> buf
pandas/_libs/window.pyx:        bufarr.data = <char *> oldbuf
```
Which should probably have the same standard as the one we're enforcing.

Just by changing the order of `'[ ->]> '` to `'[ >-]> '` makes it work as expected. But there is an additional problem on this grep. In #22854 I'm moving `code_checks.py` from travis to azure. And I implemented a bash function `invgrep` that is like a grep, that besides inverting the exit status of grep, formats the output in a way that looks nicer in azure. And pipping  two greps together is making things a bit more complex, so I'd prefer to avoid it if possible.

So, the proposed changes in this PR, create a new regex that tries to solve the problem with a single grep. I changed the pattern to match any alphanumberic of star followed by the greater than and the space. But equivalent to what you were doing, we can also use `'[^ ^>^-]> '`. Happy to change to it if it makes more sense to you.

If you can confirm that my assumptions are correct, I'll fix the pending cases in this PR, so the CI is green and we can merge.

Labels:
name: Bug
name: CI
description: Continuous Integration
name: Code Style
description: Code style, linting, code_checks

Comments:
Yep, good catch.
can you fix the issues as well so that this passes
Wanted to make sure I was not misunderstanding the problem first. All fixed, and made the the regex more robust too (one case in `validate.pyx` was not caught with your expression or mine before, not sure why, but it is now).

CI should finish on green now.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23486?src=pr&el=h1) Report
> Merging [#23486](https://codecov.io/gh/pandas-dev/pandas/pull/23486?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/8586644429a8c0054a74e645830601419da6613f?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/23486/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/23486?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #23486   +/-   ##
=======================================
  Coverage   92.23%   92.23%           
=======================================
  Files         161      161           
  Lines       51197    51197           
=======================================
  Hits        47220    47220           
  Misses       3977     3977
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.61% <ø> (ø)` | :arrow_up: |
| #single | `42.27% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23486?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/23486/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `96.41% <0%> (ø)` | :arrow_up: |
| [pandas/core/indexes/api.py](https://codecov.io/gh/pandas-dev/pandas/pull/23486/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9hcGkucHk=) | `99% <0%> (ø)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/23486/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `96.81% <0%> (ø)` | :arrow_up: |
| [pandas/core/arrays/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/23486/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lcy5weQ==) | `98.84% <0%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23486?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23486?src=pr&el=footer). Last update [8586644...356dce5](https://codecov.io/gh/pandas-dev/pandas/pull/23486?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

thanks @datapythonista