openfisca / openfisca-core

OpenFisca core engine. See other repositories for countries-specific code & data.
https://openfisca.org
GNU Affero General Public License v3.0
168 stars 75 forks source link

[7/17] Encapsulate periods module #1138

Open bonjourmauko opened 2 years ago

bonjourmauko commented 2 years ago

Part of #1061 Part of #1062 Part of #1063 Supersedes #1139 Supersedes #1043 Depended upon by #1146

Breaking changes

Renames
Deprecations
Structural changes

Technical changes

Bug fixes

MattiSG commented 2 years ago

In order to ease future reviews, when you open a PR that depends on another one, could you please make it explicit in the description? 🙂 This will make it easier to review 😊

bonjourmauko commented 2 years ago

Thank you for these contributions! I still don't understand how to validate doctests, and I suffered a lot from trying to set them straight (cf. #1134). I see here that we in the end ignore errors for the “periods” module. If that is indeed the case, then could you help me understand what is the point of “fixing” those tests? 🙂

Hi. Actually this PR make periods' doctest run (that's how I fixed them), so for them to be part of the test suite. What is ignored, at least for now, are tests' type checks, that's it.

Doctests are valuable in that they're the rare expression of unit tests in this library, coming from the contributors who gave birth to much the codebase.

bonjourmauko commented 2 years ago

Hello @MattiSG ! I hope to have addressed all of your concerns. I have also updated the description to make it clear that this PR only addresses "tests", including those in the docstrings (doctests).

bonjourmauko commented 2 years ago

I cannot review this as it depends on #1141 that is disputed, and I don't support changing so many dependencies in an untestable way (cf. #1140 (comment)).

Understood.

In order to ease reviews, could you please avoid force pushing once the PR has been opened, and rely instead on fixup commits if necessary? 🙂 Otherwise, I cannot rely on GitHub’s presentation of what has “changed since last review”, forcing me to spend time reviewing the same changeset again.

OK.

bonjourmauko commented 2 years ago

@MattiSG I've had cleanup as much as I can.

IMHO both readability and test coverage have improved, which is a triple win:

  1. We know several functions to deprecate soon.
  2. We can now more safely extend periods! :) (I've found some bugs downstream already).
  3. I forgot this one (something related to types, contracts, and maintainability).
bonjourmauko commented 1 year ago

Hmm I did a git mv but it still marked it as deleted.

bonjourmauko commented 1 year ago

It might be worthwhile to run openfisca-france using this PR to fix here and there the impacts on a large "prod" repo.

@benjello This pull request doesn't add any feature but deprecates some and fixes several bugs. In general, it renders the whole module more reliable, as many edge-cases that went silent before will now yield a useful error. Yet, of course, that means breaking changes as the range of the acceptable shrunk. It's a fair trade-off and a much needed contribution, but requires thorough testing. I'd be ideal to run this against France with population data 🏛️

benjello commented 1 year ago

@maukoquiroga : as is it breaks openfisca-france test because period method is deprecated and replaced by build_period so it might be efficient to migrate the changes in openfisca-france concomitantly.

What do you think @sandcha @MattiSG ?

bonjourmauko commented 1 year ago

@maukoquiroga : as is it breaks openfisca-france test because period method is deprecated and replaced by build_period so it might be efficient to migrate the changes in openfisca-france concomitantly.

What do you think @sandcha @MattiSG ?

The rename is a find & replace, I'm more wondering if the stringer contracts will break parts of the model. For example, some cases returning None now fail, invalid periods like 2022-1-1 also fail, etc.

Would this be suitable @MattiSG for your proposal of a release candidate?

MattiSG commented 1 year ago

Would this be suitable @MattiSG for your proposal of a release candidate?

Yes, of course, this is a good case for #1159. But I want to stress once more that #1159 is not about allowing the use of release candidates, but about allowing replacing code review by extensive testing in some contexts. In the given case, I understand that @benjello says testing on France would be welcome. If you want to simplify that testing by using a release candidate (as opposed to a local clone), sure, do it! No need for #1159 for that 😉

bonjourmauko commented 1 year ago

@eraviart What do you think?