Skip to content

Commit

Permalink
Add documentation for dispatch decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauko Quiroga committed Feb 27, 2019
1 parent 8d50ba4 commit aa0c0af
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions openfisca_france_data/erfs_fpr/get_survey_scenario.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-


from typing import Optional

from multipledispatch import dispatch # type: ignore

from openfisca_core.reforms import Reform # type: ignore
Expand Down Expand Up @@ -58,31 +60,31 @@ def get_survey_scenario(
return survey_scenario


@dispatch(TaxBenefitSystem, Reform) # type: ignore
def get_tax_benefit_system(tax_benefit_system: TaxBenefitSystem, reform: Reform) -> TaxBenefitSystem:
return tax_benefit_system


# Appelé quand *tax_benefit_system* est un :class:`TaxBenefitSystem`
@dispatch(TaxBenefitSystem, object) # type: ignore
def get_tax_benefit_system(tax_benefit_system: TaxBenefitSystem, reform: None) -> TaxBenefitSystem:
def get_tax_benefit_system(tax_benefit_system: TaxBenefitSystem, reform: Optional[None]) -> TaxBenefitSystem:
return tax_benefit_system


# Appelé quand *tax_benefit_system* est `None`, mais *reform* est une :class:`Reform`
@dispatch(object, Reform) # type: ignore
def get_tax_benefit_system(tax_benefit_system: None, reform: Reform) -> TaxBenefitSystem:
return reform(france_data_tax_benefit_system)


# Appelé quand *tax_benefit_system* et *reform* sont `None`
@dispatch(object, object) # type: ignore
def get_tax_benefit_system(tax_benefit_system: None, reform: None) -> TaxBenefitSystem:
return france_data_tax_benefit_system


# Appelé quand *tax_benefit_system* est un :class:`TaxBenefitSystem`
@dispatch(TaxBenefitSystem) # type: ignore
def get_baseline_tax_benefit_system(tax_benefit_system: TaxBenefitSystem) -> TaxBenefitSystem:
return tax_benefit_system


# Appelé quand *tax_benefit_system* est `None`
@dispatch(object) # type: ignore
def get_baseline_tax_benefit_system(tax_benefit_system: None) -> TaxBenefitSystem:
return france_data_tax_benefit_system

0 comments on commit aa0c0af

Please sign in to comment.