Gender plugins - Betty documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# Gender plugins

Type | `betty.ancestry.gender.Gender`
Repository | `betty.project.Project.gender_repository`

## Creating a gender

1. Create a new class that extends `betty.ancestry.gender.Gender` and implements the abstract methods, for example:

       from typing import override
       from betty.ancestry.gender import Gender
       from betty.machine_name import MachineName

       class MyGender(Gender):
         @override
         @classmethod
         def plugin_id(cls) -> MachineName:
             return "my-module-my-gender"

         # Implement remaining abstract methods...
         ...

2. Tell Betty about your gender by registering it as an entry point. Given the gender above in a module `my_package.my_module`, add the following to your Python package:

pyproject.toml

    [project.entry-points.'betty.gender']
    'my-module-my-gender' = 'my_package.my_module.MyGender'

setup.py

    SETUP = {
        'entry_points': {
            'betty.gender': [
                'my-module-my-gender=my_package.my_module.MyGender',
            ],
        },
    }
    if __name__ == '__main__':
        setup(**SETUP)

## See also

Read more about how to use genders and Betty’s built-in genders at Gender.