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:
Python Software Foundation Code of Conduct (in particular, the
Our Community
andOur Standards: Inappropriate Behavior
sections)How to Ask Questions the Smart Way (note that some of the showcased responses to “stupid questions” may not be acceptable)
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¶
Ensure that you have installed Git LFS.
Clone your fork of the repository.
Install Git LFS Git hooks in this repository:
git lfs install
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….)Ensure that you have installed Hatch via Pipx:
pipx install hatch
Install Git pre-commit and pre-push hooks:
hatch --env develop run pre-commit install --config .auxiliary/configuration/pre-commit.yaml
Installation Updates¶
Run:
git pull
Remove the Hatch virtual environments:
hatch env prune
Python Interpreter¶
Run:
hatch --env develop run python
Shell¶
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 afrom
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 frigid.__
¶
Common constants, imports, and utilities.
- class frigid.__.Absent¶
Bases:
Falsifier
,InternalObject
Type of the sentinel for option without default value.
- class frigid.__.ConcealerExtension¶
Bases:
object
Conceals instance attributes according to some criteria.
By default, public attributes are displayed.
- frigid.__.DictionaryProxy¶
alias of
MappingProxyType
- class frigid.__.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.
- removeprefix(prefix, /)¶
Return a str with the given prefix string removed if present.
If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.
- removesuffix(suffix, /)¶
Return a str with the given suffix string removed if present.
If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.
- 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 substrings in the string, using sep as the separator string.
- sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.
- maxsplit
Maximum number of splits (starting from the left). -1 (the default value) means no limit.
Splitting starts at the end of the string and works 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 substrings in the string, using sep as the separator string.
- sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace character (including \n \r \t \f and spaces) and will discard empty strings from the result.
- maxsplit
Maximum number of splits (starting from the left). -1 (the default value) means no limit.
Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.
- 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.
- class frigid.__.Falsifier¶
Bases:
object
Produces falsey objects.
Why not something already in Python?
object
produces truthy objects.types.NoneType
“produces” falseyNone
singleton.typing_extensions.NoDefault
is truthy singleton.
- class frigid.__.ImmutableDictionary(*iterables: Annotated[Mapping[_H, _V] | Iterable[tuple[_H, _V]], Doc('Zero or more iterables from which to initialize dictionary data. Each iterable must be dictionary or sequence of key-value pairs. Duplicate keys will result in an error.')], **entries: Annotated[_V, Doc('Zero or more keyword arguments from which to initialize dictionary data.')])¶
Bases:
ConcealerExtension
,dict
[_H
,_V
],Generic
[_H
,_V
]Immutable subclass of
dict
.Can be used as an instance dictionary.
Prevents attempts to mutate dictionary via inherited interface.
- clear() Never ¶
Raises exception. Cannot clear immutable 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: ~frigid.__._H, default: ~frigid.__._V | ~frigid.__.Absent = <frigid.__.Absent object>) Never ¶
Raises exception. Cannot pop immutable entry.
- popitem() Never ¶
Raises exception. Cannot pop immutable 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: Annotated[Mapping[_H, _V] | Iterable[tuple[_H, _V]], Doc('Zero or more iterables from which to initialize dictionary data. Each iterable must be dictionary or sequence of key-value pairs. Duplicate keys will result in an error.')], **entries: Annotated[_V, Doc('Zero or more keyword arguments from which to initialize dictionary data.')]) None ¶
Raises exception. Cannot perform mass update.
- values() an object providing a view on D's values ¶
- class frigid.__.InternalClass(name: str, bases: tuple[type, ...], namespace: dict[str, Any], *, decorators: Iterable[Callable[[type], type]] = (), **args: Any)¶
Bases:
type
Concealment and immutability on class attributes.
- mro()¶
Return a type’s method resolution order.
- class frigid.__.InternalObject¶
Bases:
ConcealerExtension
Concealment and immutability on instance attributes.
- frigid.__.Module¶
alias of
ModuleType
- class frigid.__.SimpleNamespace¶
Bases:
object
A simple attribute-based namespace.
SimpleNamespace(**kwargs)
- frigid.__.TypeofNotImplemented¶
alias of
NotImplementedType
- frigid.__.partial_function¶
alias of
partial
- frigid.__.abstract_member_function(funcobj)¶
A decorator indicating abstract methods.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal ‘super’ call mechanisms. abstractmethod() may be used to declare abstract methods for properties and descriptors.
Usage:
- class C(metaclass=ABCMeta):
@abstractmethod def my_abstract_method(self, …):
…
- frigid.__.clean_docstring(doc)¶
Clean up indentation from docstrings.
Any whitespace that can be uniformly removed from the second line onwards is removed.
- frigid.__.discover_public_attributes(attributes: Mapping[str, Any]) tuple[str, ...] ¶
Discovers public attributes of certain types from dictionary.
By default, callables, including classes, are discovered.
Module frigid._annotations
¶
Standard annotations across Python versions.
Module frigid._docstrings
¶
Docstrings table for reuse across subpackages.
Release Process¶
Initial Release Candidate¶
Checkout
master
branch.Pull from upstream to ensure all changes have been synced.
Checkout new release branch:
release-<major>.<minor>
.Bump alpha to release candidate. Commit.
hatch --env develop version rc
Tag.
git tag v${rc_version}
Push release branch and tag to upstream with tracking enabled.
Checkout
master
branch.Bump alpha to next minor version on
master
branch. Commit.hatch --env develop version minor,alpha
- Tag.
git tag v${alpha_version}
Release¶
Checkout release branch.
Bump release candidate to release. Commit.
hatch --env develop version release
Run Towncrier. Commit.
hatch --env develop run towncrier build --keep --version ${release_version}
Tag.
git tag v${release_version}
Push release branch and tag to upstream.
Wait for the release workflow to complete successfully.
Clean up news fragments to prevent recycling in future releases. Commit.
git rm documentation/towncrier/*.rst git commit -m "Clean up news fragments."
Push cleanup commit to upstream.
Cherry-pick Towncrier commits back to
master
branch.
Postrelease Patch¶
Checkout release branch.
Develop and test patch against branch. Add Towncrier entry. Commit.
Bump release to patch or increment patch number. Commit.
hatch --env develop version patch
Run Towncrier. Commit.
hatch --env develop run towncrier build --keep --version ${patch_version}
Tag.
git tag v${patch_version}
Push release branch and tag to upstream.
Wait for the release workflow to complete successfully.
Clean up news fragments to prevent recycling in future releases. Commit.
git rm documentation/towncrier/*.rst git commit -m "Clean up news fragments."
Push cleanup commit to upstream.
Cherry-pick patch and Towncrier commits back to
master
branch, resolving conflicts as necessary.