Contribution

Contribution to this project is welcome! However, it must follow the code of conduct for the project.

Code of Conduct

Please act in the spirit of respect for others, whether you are asking questions, providing feedback, or answering questions. Volunteers power much of the open source available for you to use, and they have real emotional states that can be affected by your interactions.

Specific Considerations

  • Asking Questions: Follow the Stack Overflow guidelines on how to ask a good question.

  • Answering Questions: Follow the Stack Overflow guidelines on how to write a good answer. However, avoid responses like “don’t do that,” as they can be perceived as condescending. Recommend rather than command.

  • No Egotism: Argue by facts and reason, not by appeals to authority or perceived popular opinion.

  • Differences of Opinion: Understand that people will have differences of opinion and that every design or implementation choice carries trade-offs and costs. There is seldom a right answer.

  • Constructive Critique: Keep unstructured critique to a minimum. If you have solid ideas experiment with them in a fork.

  • No Disruptive Behavior: Any spamming, trolling, flaming, baiting, or other attention-stealing behavior is not welcome.

  • Avoid Sensitive Issues: Do not engage in offensive or sensitive topics, particularly if they are off-topic. This can lead to unnecessary fights, hurt feelings, and damaged trust.

  • Avoid Noise: Do not create noise with “+1” or “me too” comments. Add only substantive comments that advance the understanding of an issue. Use appropriate reaction mechanisms to upvote comments.

Inspirations

This code of conduct is inspired, in part, by the following sources, which are worth reading:

Note

Please do not contact the authors of the above documents for anything related to this project.

Ways to Contribute

  • File bug reports and feature requests in the issue tracker. (Please try to avoid duplicate issues.)

  • Fork the repository and submit pull requests to improve the library or its documentation.

Development

Initial Installation

  1. Ensure that you have installed Git LFS.

  2. Clone your fork of the repository.

  3. Install Git LFS Git hooks in this repository:

    git lfs install
    
  4. Ensure that you have installed Pipx. (If installing via pip, you will want to use your system Python rather than the current global Python provided by Asdf, Mise, Pyenv, etc….)

  5. Ensure that you have installed Hatch via Pipx:

    pipx install hatch
    
  6. Ensure that you have installed pre-commit via Pipx:

    pipx install pre-commit
    
  7. Install Git pre-commit and pre-push hooks:

    pre-commit install --config .auxiliary/configuration/pre-commit.yaml
    

Installation Updates

  1. Run:

    git pull
    
  2. Remove the Hatch virtual environments:

    hatch env prune
    

Python Interpreter

  1. Run:

    hatch --env develop run python
    

Shell

  1. Run:

    hatch --env develop shell
    

Guidelines

  • Be sure to install the Git hooks, as mentioned in the Installation section. This will save you turnaround time from pull request validation failures.

  • Maintain or improve the current level of code coverage. Even if code coverage is at 100%, consider cases which are not explicitly tested.

  • Allow natural and expected Python exceptions to pass through the application programming interface boundary. Raise an exception from the library for any failure condition that arises from the use of the provided features that are part of the interfaces of the underlying Python object types or functions.

  • Never swallow exceptions. Either chain a __cause__ with a from original exception or raise a new exception with original exception as the __context__.

  • Avoid ancillary imports into a module namespace. Instead, place common imports into the __ base module or import at the function level. This avoids pollution of the module namespace, which should only have public attributes which relate to the interface that it is providing. This also makes functions more relocatable, since they carry their dependencies with them rather than rely on imports within the module which houses them.

  • Documentation must be written as Sphinx reStructuredText. The docstrings for functions must not include parameter or return type documentation. Parameter and return type documentation is handled via PEP 727 annotations. Pull requests, which include Markdown documentation or which attempt to provide function docstrings in the style of Google, NumPy, Sphinx, etc…, will be rejected.

  • Respect the existing code style. Pull requests, which attempt to enforce the black style or another style, will be rejected. A summary of the style is:

    • Spacing: Use spaces between identifiers and other tokens. Modern writing systems use this convention, which emerged around the 7th century of the Common Era, to improve readability. Computer code can generally be written this way too… also to improve readability.

    • Line Width: Follow PEP 8 on this: no more than 79 columns for code lines. Consider how long lines affect display on laptops or side-by-side code panes with enlarged font sizes. (Enlarged font sizes are used to reduce eye strain and allow people to code without visual correction.)

    • Vertical Compactness: Function definitions, loop bodies, and condition bodies, which consist of a single statement and which are sufficiently short, should be placed on the same line as the statement that introduces the body. Blank lines should not be used to group statements within a function body. If you need to group statements within a function body, then perhaps the function should be refactored. Function bodies should not be longer than thirty lines. I.e., one should not have to scroll to read a function.

  • Use long option names, whenever possible, in command line examples.

Internal Development Interface

Module accretive.__

Common constants, imports, and utilities.

accretive.__.ABCFactory

alias of ABCMeta

accretive.__.AbstractDictionary

alias of Mapping

class accretive.__.ClassConcealerExtension

Bases: type

Conceals class attributes according to some criteria.

By default, public attributes are displayed.

mro()

Return a type’s method resolution order.

class accretive.__.ConcealerExtension

Bases: object

Conceals instance attributes according to some criteria.

By default, public attributes are displayed.

class accretive.__.CoreDictionary(*iterables: Mapping[Hashable, typing_extensions.Any] | Iterable[Tuple[Hashable, typing_extensions.Any]][Mapping[Hashable, Any] | Iterable[Tuple[Hashable, Any]]], **entries: Any[Any])

Bases: ConcealerExtension, dict

Accretive subclass of dict.

Can be used as an instance dictionary.

Prevents attempts to mutate dictionary via inherited interface.

clear() Never

Raises exception. Cannot clear indelible entries.

copy() Self

Provides fresh copy of dictionary.

fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(key: ~typing.Hashable, default: ~typing_extensions.Any = <object object>) Never

Raises exception. Cannot pop indelible entry.

popitem() Never

Raises exception. Cannot pop indelible entry.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update(*iterables: Mapping[Hashable, typing_extensions.Any] | Iterable[Tuple[Hashable, typing_extensions.Any]][Mapping[Hashable, Any] | Iterable[Tuple[Hashable, Any]]], **entries: Any[Any]) Self

Adds new entries as a batch.

values() an object providing a view on D's values
accretive.__.DictionaryProxy

alias of mappingproxy

class accretive.__.Docstring

Bases: str

Dedicated docstring container.

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the words in the string, using sep as the delimiter string.

sep

The delimiter according which to split the string. None (the default value) means split according to any whitespace, and discard empty strings from the result.

maxsplit

Maximum number of splits to do. -1 (the default value) means no limit.

Splits are done starting at the end of the string and working to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the words in the string, using sep as the delimiter string.

sep

The delimiter according which to split the string. None (the default value) means split according to any whitespace, and discard empty strings from the result.

maxsplit

Maximum number of splits to do. -1 (the default value) means no limit.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

accretive.__.Module

alias of module

class accretive.__.SimpleNamespace

Bases: object

A simple attribute-based namespace.

SimpleNamespace(**kwargs)

accretive.__.partial_function

alias of partial

accretive.__.clean_docstring(doc)

Clean up indentation from docstrings.

Any whitespace that can be uniformly removed from the second line onwards is removed.

accretive.__.discover_fqname(obj: Any) str

Discovers fully-qualified name for class of instance.

accretive.__.discover_public_attributes(attributes: Mapping[str, Any]) Tuple[str, ...]

Discovers public attributes of certain types from dictionary.

By default, callables, including classes, are discovered.

accretive.__.generate_docstring(*fragment_ids: Type | Docstring | str) str

Sews together docstring fragments into clean docstring.

accretive.__.reclassify_modules(attributes: Mapping[str, Any], to_class: Type[module]) None

Reclassifies modules in dictionary with custom module type.

Module accretive._annotations

Standard annotations across Python versions.

Module accretive._docstrings

Docstrings table for reuse across subpackages.

Release Process

Initial Release Candidate

  1. Checkout master branch.

  2. Pull from upstream to ensure all changes have been synced.

  3. Checkout new release branch: release-<major>.<minor>.

  4. Bump alpha to release candidate. Commit.

    hatch --env develop version rc
    
  5. Run Towncrier. Commit.

    hatch --env develop run towncrier build
    
  6. Tag.

    git tag v${rc_version}
    
  1. Push release branch and tag to upstream with tracking enabled.

  2. Checkout master branch.

  3. Bump alpha to next minor version on master branch. Commit.

    hatch --env develop version minor,alpha
    
  4. Cherry-pick Towncrier commit back to master branch.

  5. Tag.

    git tag v${alpha_version}
    

Release

  1. Checkout release branch.

  2. Bump release candidate to release. Commit.

    hatch --env develop version release
    
  3. Tag.

    git tag v${release_version}
    
  4. Push release branch and tag to upstream.

Postrelease Patch

  1. Checkout release branch.

  2. Develop and test patch against branch. Add Towncrier entry. Commit.

  3. Bump release to patch or increment patch number. Commit.

    hatch --env develop version patch
    
  4. Run Towncrier. Commit.

    hatch --env develop run towncrier build
    
  5. Tag.

    git tag v${patch_version}
    
  6. Push release branch and tag to upstream.

  7. Cherry-pick patch and Towncrier commit back to master branch, resolving conflicts as necessary.