pydantic / pydantic-extra-types

Extra Pydantic types.
MIT License
181 stars 48 forks source link

Add language code definitions and test #141

Closed 07pepa closed 6 months ago

07pepa commented 6 months ago

I added language definitions

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (e186814) to head (e30ac0a). Report is 4 commits behind head on main.

:exclamation: Current head e30ac0a differs from pull request most recent head 1fff4e3. Consider uploading reports for the commit 1fff4e3 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #141 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 11 12 +1 Lines 685 724 +39 Branches 169 179 +10 ========================================= + Hits 685 724 +39 ```

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

yezz123 commented 6 months ago

Hello @07pepa That's a great start for the PR, but we should now add Pydantic CoreSchema & the validation - check here an example, also including a test for JSON schema - check here

07pepa commented 6 months ago

Hello @07pepa That's a great start for the PR, but we should now add Pydantic CoreSchema & the validation - check here an example, also including a test for JSON schema - check here

I am not sure how/why to add this to literal (since it is supported by pydantic) also litteral is recomended for "enumerations" https://docs.pydantic.dev/latest/concepts/performance/#use-literal-not-enum

I am not sure what you want me to do. please tell me how to do it or just modify the code.. i am fine with that.

Only thing i would add now is a check if all codes are supported with help of some online source of truth (but that would complicate the test code considerably. and we would have to decide on source of truth

yezz123 commented 6 months ago

Hello @07pepa,

Thank you for your contribution! This PR is indeed valuable, particularly in terms of structuring the data. However, I'd like to propose an enhancement, we can use pycountry for not only countries but also languages, this ensuring consistency and using existing resources already.

As we're already utilizing pycountry for country data, integrating language support from pycountry seems like a natural extension. By doing so, we can ensure uniformity and benefit from the robustness of pycountry's language code support.

Here are some initial resources to help kickstart this integration:

Once we establish a similar structure as the one we have for countries in country.py, we can seamlessly support language codes as well. This enhancement would be highly beneficial. Thank you for considering it! 🙏🏻

07pepa commented 6 months ago

good point i will look in detail on monday

07pepa commented 6 months ago

@yezz123 i am finished .... and test are passing (test are exhaustive)

can you add your input on this code or just merge it .... i will probably add curecies next