faker icon indicating copy to clipboard operation
faker copied to clipboard

feat: extract sex generator from name.gender to name.sex

Open hankucz opened this issue 1 year ago • 8 comments

Fixes #353 Fixes #776

  • extract sex generator from name.gender to name.sex
  • deprecate name.gender(true), which generated binary gender, what we would consider now as sex
  • rename locale definitions from bianry_gender to sex
  • lowercase english values for sex
  • extend english locale with non-binary

hankucz avatar Jul 19 '22 11:07 hankucz

Codecov Report

Merging #1168 (ca21e20) into main (ca7cb41) will increase coverage by 0.00%. The diff coverage is 97.77%.

@@           Coverage Diff           @@
##             main    #1168   +/-   ##
=======================================
  Coverage   99.62%   99.62%           
=======================================
  Files        2158     2159    +1     
  Lines      240193   240217   +24     
  Branches     1003     1005    +2     
=======================================
+ Hits       239294   239325   +31     
+ Misses        878      871    -7     
  Partials       21       21           
Impacted Files Coverage Δ
src/definitions/name.ts 0.00% <0.00%> (ø)
src/locales/fr/name/sex.ts 100.00% <ø> (ø)
src/locales/fr_CH/name/sex.ts 100.00% <ø> (ø)
src/locales/pt_BR/name/sex.ts 100.00% <ø> (ø)
src/locales/ur/name/sex.ts 100.00% <ø> (ø)
src/locales/de/name/index.ts 100.00% <100.00%> (ø)
src/locales/de/name/sex.ts 100.00% <100.00%> (ø)
src/locales/en/name/index.ts 100.00% <100.00%> (ø)
src/locales/en/name/sex.ts 100.00% <100.00%> (ø)
src/locales/fr/name/index.ts 100.00% <100.00%> (ø)
... and 7 more

codecov[bot] avatar Jul 19 '22 12:07 codecov[bot]

This is a breaking change as binary_gender could be used in faker.faker('{{binary_gender}}') without that we know it or users know that it had changed I mark this as blocked for now and would like to first discuss if this PR is needed anyway

If we are killing gender enum, it feels like this is a natural good step forward to make the differentiation between gender and sex.

In my opinion faker.fake should be deprecated, as the same result can be achieved with string templates, which additionally allow user to provide options to method calls, instead of just using locales.

So yes, technically it could be a breaking change, but at the same time locale formats are not officially published, so I have doubts if anybody would hook up to the internals so deep to find it. And if he did, it's kind of not our fault...

@ST-DDT @xDivisionByZerox wdyt?

pkuczynski avatar Jul 26 '22 17:07 pkuczynski

In my opinion faker.fake should be deprecated, as the same result can be achieved with string templates, which additionally allow user to provide options to method calls, instead of just using locales.

TBH, I'm with you on this one. Never understood the use of fake at all. Gues its legacy from pre-v5.5.

So yes, technically it could be a breaking change, but at the same time locale formats are not officially published, so I have doubts if anybody would hook up to the internals so deep to find it. And if he did, it's kind of not our fault...

Not "technically". In this case, it is since the feature to use locale definition with fake is documented AND promoted by using it in our own codebase. Have a look at these deprecation statements:

https://github.com/faker-js/faker/blob/ca7cde59ec3747a93d1d47355a83287696628eb5/src/modules/address/index.ts#L103-L109

https://github.com/faker-js/faker/blob/ca7cde59ec3747a93d1d47355a83287696628eb5/src/modules/address/index.ts#L126-L132

So for me, there is no question whether renaming binary_gender is a breaking change. It clearly is.

xDivisionByZerox avatar Jul 26 '22 19:07 xDivisionByZerox

TBH, I'm with you on this one. Never understood the use of fake at all. Gues its legacy from pre-v5.5.

See my (same) comment https://github.com/faker-js/faker/pull/1161#issuecomment-1195852602

Not "technically". In this case, it is since the feature to use locale definition with fake is documented AND promoted by using it in our own codebase. Have a look at these deprecation statements:

https://github.com/faker-js/faker/blob/ca7cde59ec3747a93d1d47355a83287696628eb5/src/modules/address/index.ts#L103-L109

https://github.com/faker-js/faker/blob/ca7cde59ec3747a93d1d47355a83287696628eb5/src/modules/address/index.ts#L126-L132

So for me, there is no question whether renaming binary_gender is a breaking change. It clearly is.

These are two statements that do not mention binary_gender, so it's unlikely someone would be using it. Especially this data is provided in 5 locales only, so very few... So yes, this is technically breaking, but the impact is low...

pkuczynski avatar Jul 26 '22 19:07 pkuczynski

What are the next steps? Should I do anything about it?

hankucz avatar Aug 01 '22 13:08 hankucz

Should we duplicate the binary_gender locale definition for now and remove it in v8? That way we could merge this PR now and don't need to wait because of the breaking change for the fake function 🤔

Shinigami92 avatar Aug 02 '22 09:08 Shinigami92

Should we duplicate the binary_gender locale definition for now and remove it in v8? That way we could merge this PR now and don't need to wait because of the breaking change for the fake function 🤔

We could if you think it's worth it. Hard to say if anybody was using it in fake, but I kind of doubt it... We should deprecate faker.helpers.fake as it does not allow us to do any kind of typings :(

pkuczynski avatar Aug 02 '22 10:08 pkuczynski

Docs-Preview (Click to expand)

grafik

grafik

ST-DDT avatar Aug 03 '22 21:08 ST-DDT

I believe I applied all of the feedback. Is there anything else I should do about it?

hankucz avatar Aug 18 '22 21:08 hankucz

Ping @ST-DDT, you need to approve to stale your requested changes

Shinigami92 avatar Aug 19 '22 07:08 Shinigami92