pandas-dev / pandas-stubs

Public type stubs for pandas
BSD 3-Clause "New" or "Revised" License
234 stars 125 forks source link

Validate all values for csv.QUOTE #991

Closed refack closed 2 months ago

refack commented 2 months ago

4 and 5 added in 3.12 (python/cpython/67230) ref: https://docs.python.org/3/library/csv.html#csv.QUOTE_NOTNULL ref: https://github.com/python/cpython/blob/a8bc03696c7c2c03e1d580633151ec7b850366f3/Modules/_csv.c#L88-L106

refack commented 2 months ago

I didn't consider the fact that this will fail in python < 3.12 since the functionality is just not there... I can put this test under a version check condition, but then should there be and if in the stub as well, one branch allowing literals up to 3 and the other up to 5?

refack commented 2 months ago

Sorry I'm both dyslexic and ESL 🤣 image

refack commented 2 months ago

~Can we depend on typeshed? They have a stub for the compiled _csv code~ https://github.com/python/typeshed/pull/12332/files#diff-c58bcb0a60afcd3168bd383c480870da81f23b9cec15e0890cf77d2306323240 ~(Even they recently moved from Literal to Final)~

Never mind, the type checkers still don't want to infer the Type at static time, and the only importable Type is just _QuotingType: TypeAlias = int https://github.com/python/typeshed/blob/e8e9291c76f50c3bcde79e7bb61060f5c24c054e/stdlib/_csv.pyi#L17-L19

Dr-Irv commented 2 months ago

Never mind, the type checkers still don't want to infer the Type at static time, and the only importable Type is just _QuotingType: TypeAlias = int https://github.com/python/typeshed/blob/e8e9291c76f50c3bcde79e7bb61060f5c24c054e/stdlib/_csv.pyi#L17-L19

Yes, I see that. I tried some other ideas and they just didn't work.