nocaselist - A case-insensitive list for Python
The project web site is: https://github.com/pywbem/nocaselist
Introduction
Functionality
Class nocaselist.NocaseList
is a case-insensitive list that preserves
the lexical case of its items.
Example:
$ python
>>> from nocaselist import NocaseList
>>> list1 = NocaseList(['Alpha', 'Beta'])
>>> print(list1) # Any access is case-preserving
['Alpha', 'Beta']
>>> 'ALPHA' in list1 # Any lookup or comparison is case-insensitive
True
The NocaseList
class supports the functionality of the
built-in list class of Python 3.8 on all Python versions it supports (except
for being case-insensitive, of course). This includes the clear()
and
copy()
methods added in Python 3.3 to the built-in list
class.
The case-insensitivity is achieved by matching any key values as their casefolded values. By default, the casefolding is performed as follows:
On Python 3, with
str.casefold()
for unicode string keys and withbytes.lower()
for byte string keys.On Python 2, with
str.lower()
.
The str.casefold()
method implements the casefolding algorithm
described in Default Case Folding in The Unicode Standard.
The default casefolding can be overridden with a user-defined casefold method.
Overriding the default casefold method
The case-insensitive behavior of the NocaseList
class
is implemented in its __casefold__()
method. That
method returns the casefolded value for the case-insensitive list items.
The default implementation of the __casefold__()
method calls str.casefold()
on Python 3 and str.lower()
on
Python 2. The str.casefold()
method implements the casefolding
algorithm described in Default Case Folding in The Unicode Standard.
If it is necessary to change the case-insensitive behavior of the
NocaseList
class, that can be done by overriding its
__casefold__()
method.
The following Python 3 example shows how your own casefold method would be used, that normalizes the value in addition to casefolding it:
from NocaseList import NocaseList
from unicodedata import normalize
class MyNocaseList(NocaseList):
@staticmethod
def __casefold__(value):
return normalize('NFKD', value).casefold()
mylist = MyNocaseList()
# Add item with combined Unicode character "LATIN CAPITAL LETTER C WITH CEDILLA"
mylist.append("\u00C7")
# Look up item with combination sequence of lower case "c" followed by "COMBINING CEDILLA"
"c\u0327" in mylist # True
Supported environments
The package does not have any dependencies on the type of operating system and is regularly tested in GitHub Actions on the following operating systems:
Ubuntu, Windows, macOS
The package is supported and tested on the following Python versions:
Python: 2.7, 3.5 and all higher 3.x versions
Installing
The following command installs the latest version of nocaselist that is released on PyPI into the active Python environment:
$ pip install nocaselist
To install an older released version of nocaselist, Pip supports specifying a version requirement. The following example installs nocaselist version 0.1.0 from PyPI into the active Python environment:
$ pip install nocaselist==0.1.0
If you need to get a certain new functionality or a new fix that is not yet part of a version released to PyPI, Pip supports installation from a Git repository. The following example installs nocaselist from the current code level in the master branch of the nocaselist repository:
$ pip install git+https://github.com/pywbem/nocaselist.git@master#egg=nocaselist
Verifying the installation
You can verify that nocaselist is installed correctly by importing the package into Python (using the Python environment you installed it to):
$ python -c "import nocaselist; print('ok')"
ok
Package version
The version of the nocaselist package can be accessed by
programs using the nocaselist.__version__
variable:
- nocaselist._version.__version__ = '1.1.2'
The full version of this package including any development levels, as a string.
Possible formats for this version string are:
“M.N.P.dev1”: Development level 1 of a not yet released version M.N.P
“M.N.P”: A released version M.N.P
Note: For tooling reasons, the variable is shown as
nocaselist._version.__version__
, but it should be used as
nocaselist.__version__
.
Compatibility and deprecation policy
The nocaselist project uses the rules of Semantic Versioning 2.0.0 for compatibility between versions, and for deprecations. The public interface that is subject to the semantic versioning rules and specificically to its compatibility rules are the APIs and commands described in this documentation.
The semantic versioning rules require backwards compatibility for new minor versions (the ‘N’ in version ‘M.N.P’) and for new patch versions (the ‘P’ in version ‘M.N.P’).
Thus, a user of an API or command of the nocaselist project can safely upgrade to a new minor or patch version of the nocaselist package without encountering compatibility issues for their code using the APIs or for their scripts using the commands.
In the rare case that exceptions from this rule are needed, they will be documented in the Change log.
Occasionally functionality needs to be retired, because it is flawed and a better but incompatible replacement has emerged. In the nocaselist project, such changes are done by deprecating existing functionality, without removing it immediately.
The deprecated functionality is still supported at least throughout new minor or patch releases within the same major release. Eventually, a new major release may break compatibility by removing deprecated functionality.
Any changes at the APIs or commands that do introduce incompatibilities as defined above, are described in the Change log.
Deprecation of functionality at the APIs or commands is communicated to the users in multiple ways:
It is described in the documentation of the API or command
It is mentioned in the change log.
It is raised at runtime by issuing Python warnings of type
DeprecationWarning
(see the Pythonwarnings
module).
Since Python 2.7, DeprecationWarning
messages are suppressed by default.
They can be shown for example in any of these ways:
By specifying the Python command line option:
-W default
By invoking Python with the environment variable:
PYTHONWARNINGS=default
It is recommended that users of the nocaselist project
run their test code with DeprecationWarning
messages being shown, so they
become aware of any use of deprecated functionality.
Here is a summary of the deprecation and compatibility policy used by the nocaselist project, by version type:
New patch version (M.N.P -> M.N.P+1): No new deprecations; no new functionality; backwards compatible.
New minor release (M.N.P -> M.N+1.0): New deprecations may be added; functionality may be extended; backwards compatible.
New major release (M.N.P -> M+1.0.0): Deprecated functionality may get removed; functionality may be extended or changed; backwards compatibility may be broken.
API Reference
This section describes the external API of the nocaselist project. Any internal symbols and APIs are omitted.
Class NocaseList
- class nocaselist.NocaseList(iterable=())[source]
A case-insensitive and case-preserving list.
The list is case-insensitive: Whenever items of the list are looked up by value or item values are compared, that is done case-insensitively. The case-insensitivity is defined by performing the lookup or comparison on the result of the
__casefold__()
method on the on list items. None is allowed as a list value and will not be case folded.The list is case-preserving: Whenever the value of list items is returned, they have the lexical case that was originally specified when adding or updating the item.
Except for the case-insensitivity of its items, it behaves like, and is in fact derived from, the built-in
list
class in order to facilitate type checks.The implementation maintains a second list with the casefolded items of the inherited list, and ensures that both lists are in sync.
The list supports serialization via the Python
pickle
module. To save space and time, only the originally cased list is serialized.Initialize the list with the items in the specified iterable.
Methods
Append the specified value as a new item to the end of the list (and return None).
Remove all items from the list (and return None).
Return a shallow copy of the list.
Return the number of times the specified value occurs in the list, comparing the value and the list items case-insensitively.
Extend the list by the items in the specified iterable (and return None).
Return the index of the first item that is equal to the specified value, comparing the value and the list items case-insensitively.
Insert a new item with specified value before the item at the specified index (and return None).
Return the value of the item at the specified index and also remove it from the list.
Remove the first item from the list whose value is equal to the specified value (and return None), comparing the value and the list items case-insensitively.
Reverse the items in the list in place (and return None).
Sort the items in the list in place (and return None).
Attributes
Details
- static __casefold__(value)[source]
This method implements the case-insensitive behavior of the class.
It returns a case-insensitive form of the input value by calling a “casefold method” on the value. The input value will not be None.
The casefold method called by this method is
str.lower()
on Python 2, and on Python 3 it isstr.casefold()
, falling back tobytes.lower()
if it does not exist.This method can be overridden by users in order to change the case-insensitive behavior of the class. See Overriding the default casefold method for details.
- Parameters
value (str or unicode or bytes) – Input value. Will not be None.
- Returns
Case-insensitive form of the input value.
- Return type
- Raises
AttributeError – The value does not have the casefold method.
- __getstate__()[source]
Called when pickling the object, see
object.__getstate__()
.In order to save space and time, only the list with the originally cased items is saved, but not the second list with the casefolded items.
On Python 2, the ‘pickle’ module does not call
__setstate__()
, so this optimzation has only be implemented for Python 3.
- __setstate__(state)[source]
Called when unpickling the object, see
object.__setstate__()
.On Python 2, the ‘pickle’ module does not call this method, so this optimzation has only be implemented for Python 3.
- __setitem__(index, value)[source]
Update the value of the item at an existing index in the list.
Invoked using
ncl[index] = value
.- Raises
AttributeError – The value does not have the casefold method.
- __delitem__(index)[source]
Delete an item at an existing index from the list.
Invoked using
del ncl[index]
.
- __contains__(value)[source]
Return a boolean indicating whether the list contains at least one item with the value, by looking it up case-insensitively.
Invoked using
value in ncl
.- Raises
AttributeError – The value does not have the casefold method.
- __add__(other)[source]
Return a new
NocaseList
object that contains the items from the left hand operand (self
) and the items from the right hand operand (other
).The right hand operand (
other
) must be an instance oflist
(includingNocaseList
) ortuple
. The operands are not changed.Invoked using e.g.
ncl + other
- Raises
TypeError – The other iterable is not a list or tuple
- __iadd__(other)[source]
Extend the left hand operand (
self
) by the items from the right hand operand (other
).The
other
parameter must be an iterable but is otherwise not restricted in type. Thus, if it is a string, the characters of the string are added as distinct items to the list.Invoked using
ncl += other
.
- __mul__(number)[source]
Return a new
NocaseList
object that contains the items from the left hand operand (self
) as many times as specified by the right hand operand (number
).A number <= 0 causes the returned list to be empty.
The left hand operand (
self
) is not changed.Invoked using
ncl * number
.
- __rmul__(number)[source]
Return a new
NocaseList
object that contains the items from the right hand operand (self
) as many times as specified by the left hand operand (number
).A number <= 0 causes the returned list to be empty.
The right hand operand (
self
) is not changed.Invoked using
number * ncl
.
- __imul__(number)[source]
Change the left hand operand (
self
) so that it contains the items from the original left hand operand (self
) as many times as specified by the right hand operand (number
).A number <= 0 will empty the left hand operand.
Invoked using
ncl *= number
.
- __reversed__()[source]
Return a shallow copy of the list that has its items reversed in order.
Invoked using
reversed(ncl)
.
- __eq__(other)[source]
Return a boolean indicating whether the list and the other list are equal, by comparing corresponding list items case-insensitively.
The other list may be a
NocaseList
object or any other iterable. In all cases, the comparison takes place case-insensitively.Invoked using e.g.
ncl == other
.- Raises
AttributeError – A value in the other list does not have the casefold method.
- __ne__(other)[source]
Return a boolean indicating whether the list and the other list are not equal, by comparing corresponding list items case-insensitively.
The other list may be a
NocaseList
object or any other iterable. In all cases, the comparison takes place case-insensitively.Invoked using e.g.
ncl != other
.- Raises
AttributeError – A value in the other list does not have the casefold method.
- __gt__(other)[source]
Return a boolean indicating whether the list is greater than the other list, by comparing corresponding list items case-insensitively.
The other list may be a
NocaseList
object or any other iterable. In all cases, the comparison takes place case-insensitively.Invoked using e.g.
ncl > other
.- Raises
AttributeError – A value in the other list does not have the casefold method.
- __lt__(other)[source]
Return a boolean indicating whether the list is less than the other list, by comparing corresponding list items case-insensitively.
The other list may be a
NocaseList
object or any other iterable. In all cases, the comparison takes place case-insensitively.Invoked using e.g.
ncl < other
.- Raises
AttributeError – A value in the other list does not have the casefold method.
- __ge__(other)[source]
Return a boolean indicating whether the list is greater than or equal to the other list, by comparing corresponding list items case-insensitively.
The other list may be a
NocaseList
object or any other iterable. In all cases, the comparison takes place case-insensitively.Invoked using e.g.
ncl >= other
.- Raises
AttributeError – A value in the other list does not have the casefold method.
- __le__(other)[source]
Return a boolean indicating whether the list is less than or equal to the other list, by comparing corresponding list items case-insensitively.
The other list may be a
NocaseList
object or any other iterable. In all cases, the comparison takes place case-insensitively.Invoked using e.g.
ncl <= other
.- Raises
AttributeError – A value in the other list does not have the casefold method.
- count(value)[source]
Return the number of times the specified value occurs in the list, comparing the value and the list items case-insensitively.
- Raises
AttributeError – The value does not have the casefold method.
- copy()[source]
Return a shallow copy of the list.
Note: This method is supported on Python 2 and Python 3, even though the built-in list class only supports it on Python 3.
- clear()[source]
Remove all items from the list (and return None).
Note: This method is supported on Python 2 and Python 3, even though the built-in list class only supports it on Python 3.
- index(value, start=0, stop=9223372036854775807)[source]
Return the index of the first item that is equal to the specified value, comparing the value and the list items case-insensitively.
The search is limited to the index range defined by the specified
start
andstop
parameters, wherebystop
is the index of the first item after the search range.- Raises
AttributeError – The value does not have the casefold method.
ValueError – No such item is found.
- append(value)[source]
Append the specified value as a new item to the end of the list (and return None).
- Raises
AttributeError – The value does not have the casefold method.
- extend(iterable)[source]
Extend the list by the items in the specified iterable (and return None).
- Raises
AttributeError – A value in the iterable does not have the casefold method.
- insert(index, value)[source]
Insert a new item with specified value before the item at the specified index (and return None).
- Raises
AttributeError – The value does not have the casefold method.
- pop(index=-1)[source]
Return the value of the item at the specified index and also remove it from the list.
- remove(value)[source]
Remove the first item from the list whose value is equal to the specified value (and return None), comparing the value and the list items case-insensitively.
- Raises
AttributeError – The value does not have the casefold method.
- sort(key=None, reverse=False)[source]
Sort the items in the list in place (and return None).
The sort is stable, in that the order of two (case-insensitively) equal elements is maintained.
By default, the list is sorted in ascending order of its casefolded item values. If a key function is given, it is applied once to each casefolded list item and the list is sorted in ascending or descending order of their key function values.
The
reverse
flag can be set to sort in descending order.
Development
This section only needs to be read by developers of the nocaselist project, including people who want to make a fix or want to test the project.
Repository
The repository for the nocaselist project is on GitHub:
Setting up the development environment
If you have write access to the Git repo of this project, clone it using its SSH link, and switch to its working directory:
$ git clone git@github.com:pywbem/nocaselist.git $ cd nocaselist
If you do not have write access, create a fork on GitHub and clone the fork in the way shown above.
It is recommended that you set up a virtual Python environment. Have the virtual Python environment active for all remaining steps.
Install the project for development. This will install Python packages into the active Python environment, and OS-level packages:
$ make develop
This project uses Make to do things in the currently active Python environment. The command:
$ make
displays a list of valid Make targets and a short description of what each target does.
Building the documentation
The ReadTheDocs (RTD) site is used to publish the documentation for the project package at https://nocaselist.readthedocs.io/
This page is automatically updated whenever the Git repo for this package changes the branch from which this documentation is built.
In order to build the documentation locally from the Git work directory, execute:
$ make builddoc
The top-level document to open with a web browser will be
build_doc/html/docs/index.html
.
Testing
All of the following make commands run the tests in the currently active Python environment. Depending on how the nocaselist package is installed in that Python environment, either the directories in the main repository directory are used, or the installed package. The test case files and any utility functions they use are always used from the tests directory in the main repository directory.
The tests directory has the following subdirectory structure:
tests
+-- unittest Unit tests
There are multiple types of tests:
Unit tests
These tests can be run standalone, and the tests validate their results automatically.
They are run by executing:
$ make test
Test execution can be modified by a number of environment variables, as documented in the make help (execute make help).
An alternative that does not depend on the makefile and thus can be executed from the source distribution archive, is:
$ ./setup.py test
Options for pytest can be passed using the
--pytest-options
option.
To run the unit tests in all supported Python environments, the Tox tool can be used. It creates the necessary virtual Python environments and executes make test (i.e. the unit tests) in each of them.
For running Tox, it does not matter which Python environment is currently active, as long as the Python tox package is installed in it:
$ tox # Run tests on all supported Python versions
$ tox -e py27 # Run tests on Python 2.7
Testing from the source archives on Pypi or GitHub
The wheel distribution archives on Pypi (e.g. *.whl
) contain only the
files needed to run this package, but not the files needed to test it.
The source distribution archives on Pypi and GitHub (e.g. *.tar.gz
)
contain all files that are needed to run and to test this package. This allows
testing the package without having to check out the entire repository, and is
convenient for testing e.g. when packaging into OS-level packages.
Nevertheless, the test files are not installed when installing these source
distribution archives.
The following commands download the source distribution archive on Pypi for a particular version of the package into the current directory and unpack it:
$ pip download --no-deps --no-binary :all: nocaselist==1.0.0
$ tar -xf nocaselist-1.0.0.tar.gz
$ cd nocaselist-1.0.0
$ ls -1
-rw-r--r-- 1 johndoe staff 468 Jun 29 22:31 INSTALL.md
-rw-r--r-- 1 johndoe staff 26436 May 26 06:45 LICENSE.txt
-rw-r--r-- 1 johndoe staff 367 Jul 3 07:54 MANIFEST.in
-rw-r--r-- 1 johndoe staff 3451 Jul 3 07:55 PKG-INFO
-rw-r--r-- 1 johndoe staff 7665 Jul 2 23:20 README.rst
drwxr-xr-x 29 johndoe staff 928 Jul 3 07:55 nocaselist
drwxr-xr-x 8 johndoe staff 256 Jul 3 07:55 nocaselist.egg-info
-rw-r--r-- 1 johndoe staff 1067 Jun 29 22:31 requirements.txt
-rw-r--r-- 1 johndoe staff 38 Jul 3 07:55 setup.cfg
-rwxr-xr-x 1 johndoe staff 7555 Jul 3 07:24 setup.py
-rw-r--r-- 1 johndoe staff 2337 Jul 2 23:20 test-requirements.txt
drwxr-xr-x 15 johndoe staff 480 Jul 3 07:55 tests
This package, its dependent packages for running it, and its dependent packages for testing it can be installed with the package extra named “test”:
$ pip install .[test]
When testing in Linux distributions that include this package as an OS-level
package, the corresponding OS-level packages would instead be installed for
these dependent Python packages. The test-requirements.txt
file shows which
dependent Python packages are needed for testing this package.
Finally, the tests can be run using the setup.py
script:
$ ./setup.py test
These commands are listed in the help of the setup.py
script:
$ ./setup.py --help-commands
. . .
Extra commands:
. . .
test Run unit tests using pytest
. . .
The additional options supported by these commands are shown in their help:
$ ./setup.py test --help
. . .
Options for 'test' command:
--pytest-options additional options for pytest, as one argument
. . .
Note: The test
command of setup.py
is not the deprecated built-in
command (see https://github.com/pypa/setuptools/issues/1684), but has been
implemented in setup.py
in such a way that it only runs the tests but
does not install anything upfront.
Therefore, this approach can be used for testing in Linux distributions that
include this package as an OS-level package.
Contributing
Third party contributions to this project are welcome!
In order to contribute, create a Git pull request, considering this:
Test is required.
Each commit should only contain one “logical” change.
A “logical” change should be put into one commit, and not split over multiple commits.
Large new features should be split into stages.
The commit message should not only summarize what you have done, but explain why the change is useful.
What comprises a “logical” change is subject to sound judgement. Sometimes, it makes sense to produce a set of commits for a feature (even if not large). For example, a first commit may introduce a (presumably) compatible API change without exploitation of that feature. With only this commit applied, it should be demonstrable that everything is still working as before. The next commit may be the exploitation of the feature in other components.
For further discussion of good and bad practices regarding commits, see:
Further rules:
The following long-lived branches exist and should be used as targets for pull requests:
master
- for next functional versionstable_$MN
- for fix stream of released version M.N.
We use topic branches for everything!
Based upon the intended long-lived branch, if no dependencies
Based upon an earlier topic branch, in case of dependencies
It is valid to rebase topic branches and force-push them.
We use pull requests to review the branches.
Use the correct long-lived branch (e.g.
master
orstable_0.2
) as a merge target.Review happens as comments on the pull requests.
At least one approval is required for merging.
GitHub meanwhile offers different ways to merge pull requests. We merge pull requests by rebasing the commit from the pull request.
Releasing a version to PyPI
This section describes how to release a version of nocaselist to PyPI.
It covers all variants of versions that can be released:
Releasing a new major version (Mnew.0.0) based on the master branch
Releasing a new minor version (M.Nnew.0) based on the master branch
Releasing a new update version (M.N.Unew) based on the stable branch of its minor version
The description assumes that the pywbem/nocaselist Github repo is cloned locally and its upstream repo is assumed to have the Git remote name origin.
Any commands in the following steps are executed in the main directory of your local clone of the pywbem/nocaselist Git repo.
Set shell variables for the version that is being released and the branch it is based on:
MNU
- Full version M.N.U that is being releasedMN
- Major and minor version M.N of that full versionBRANCH
- Name of the branch the version that is being released is based on
When releasing a new major version (e.g.
1.0.0
) based on the master branch:MNU=1.0.0 MN=1.0 BRANCH=master
When releasing a new minor version (e.g.
0.9.0
) based on the master branch:MNU=0.9.0 MN=0.9 BRANCH=master
When releasing a new update version (e.g.
0.8.1
) based on the stable branch of its minor version:MNU=0.8.1 MN=0.8 BRANCH=stable_${MN}
Create a topic branch for the version that is being released:
git checkout ${BRANCH} git pull git checkout -b release_${MNU}
Edit the version file:
vi nocaselist/_version.py
and set the
__version__
variable to the version that is being released:__version__ = 'M.N.U'
Edit the change log:
vi docs/changes.rst
and make the following changes in the section of the version that is being released:
Finalize the version.
Change the release date to today’s date.
Make sure that all changes are described.
Make sure the items shown in the change log are relevant for and understandable by users.
In the “Known issues” list item, remove the link to the issue tracker and add text for any known issues you want users to know about.
Remove all empty list items.
Commit your changes and push the topic branch to the remote repo:
git status # Double check the changed files git commit -asm "Release ${MNU}" git push --set-upstream origin release_${MNU}
On GitHub, create a Pull Request for branch
release_M.N.U
. This will trigger the CI runs.Important: When creating Pull Requests, GitHub by default targets the
master
branch. When releasing based on a stable branch, you need to change the target branch of the Pull Request tostable_M.N
.On GitHub, close milestone
M.N.U
.On GitHub, once the checks for the Pull Request for branch
start_M.N.U
have succeeded, merge the Pull Request (no review is needed). This automatically deletes the branch on GitHub.Add a new tag for the version that is being released and push it to the remote repo. Clean up the local repo:
git checkout ${BRANCH} git pull git tag -f ${MNU} git push -f --tags git branch -d release_${MNU}
When releasing based on the master branch, create and push a new stable branch for the same minor version:
git checkout -b stable_${MN} git push --set-upstream origin stable_${MN} git checkout ${BRANCH}
Note that no GitHub Pull Request is created for any
stable_*
branch.When releasing based on the master branch, activate the new version
stable_M.N
on ReadTheDocs:Go to https://readthedocs.org/projects/nocaselist/versions/ and log in.
Activate the new version
stable_M.N
.This triggers a build of that version. Verify that the build succeeds and that new version is shown in the version selection popup at https://nocaselist.readthedocs.io/
On GitHub, edit the new tag
M.N.U
, and create a release description on it. This will cause it to appear in the Release tab.You can see the tags in GitHub via Code -> Releases -> Tags.
Upload the package to PyPI:
make upload
This will show the package version and will ask for confirmation.
Attention! This only works once for each version. You cannot release the same version twice to PyPI.
Verify that the released version arrived on PyPI at https://pypi.python.org/pypi/nocaselist/
Starting a new version
This section shows the steps for starting development of a new version of the nocaselist project in its Git repo.
This section covers all variants of new versions:
Starting a new major version (Mnew.0.0) based on the master branch
Starting a new minor version (M.Nnew.0) based on the master branch
Starting a new update version (M.N.Unew) based on the stable branch of its minor version
The description assumes that the pywbem/nocaselist Github repo is cloned locally and its upstream repo is assumed to have the Git remote name origin.
Any commands in the following steps are executed in the main directory of your local clone of the pywbem/nocaselist Git repo.
Set shell variables for the version that is being started and the branch it is based on:
MNU
- Full version M.N.U that is being startedMN
- Major and minor version M.N of that full versionBRANCH
- Name of the branch the version that is being started is based on
When starting a new major version (e.g.
1.0.0
) based on the master branch:MNU=1.0.0 MN=1.0 BRANCH=master
When starting a new minor version (e.g.
0.9.0
) based on the master branch:MNU=0.9.0 MN=0.9 BRANCH=master
When starting a new minor version (e.g.
0.8.1
) based on the stable branch of its minor version:MNU=0.8.1 MN=0.8 BRANCH=stable_${MN}
Create a topic branch for the version that is being started:
git checkout ${BRANCH} git pull git checkout -b start_${MNU}
Edit the version file:
vi nocaselist/_version.py
and update the version to a draft version of the version that is being started:
__version__ = 'M.N.U.dev1'
Edit the change log:
vi docs/changes.rst
and insert the following section before the top-most section:
nocaselist M.N.U.dev1 --------------------- Released: not yet **Incompatible changes:** **Deprecations:** **Bug fixes:** **Enhancements:** **Cleanup:** **Known issues:** * See `list of open issues`_. .. _`list of open issues`: https://github.com/pywbem/nocaselist/issues
Commit your changes and push them to the remote repo:
git status # Double check the changed files git commit -asm "Start ${MNU}" git push --set-upstream origin start_${MNU}
On GitHub, create a Pull Request for branch
start_M.N.U
.Important: When creating Pull Requests, GitHub by default targets the
master
branch. When starting a version based on a stable branch, you need to change the target branch of the Pull Request tostable_M.N
.On GitHub, create a milestone for the new version
M.N.U
.You can create a milestone in GitHub via Issues -> Milestones -> New Milestone.
On GitHub, go through all open issues and pull requests that still have milestones for previous releases set, and either set them to the new milestone, or to have no milestone.
On GitHub, once the checks for the Pull Request for branch
start_M.N.U
have succeeded, merge the Pull Request (no review is needed). This automatically deletes the branch on GitHub.Update and clean up the local repo:
git checkout ${BRANCH} git pull git branch -d start_${MNU}
Appendix
This section contains information that is referenced from other sections, and that does not really need to be read in sequence.
References
Change log
nocaselist 1.1.2
Released: 2023-05-01
Incompatible changes:
Removed support for Python 3.4. It is unsupported by the PSF since 3/2019 and recently, Github Actions removed the ubuntu18.04 image which was the last one with Python 3.4 support.
Bug fixes:
Docs: Fixed description of default casefold method for Python 2.
Fixed coveralls issues with KeyError and HTTP 422 Unprocessable Entity.
nocaselist 1.1.1
Released: 2023-02-26
Bug fixes:
Fixed new issues from Pylint 2.16
Enhancements:
Resurrected support for byte strings as list values in the default implementation of the casefold method. The list can now contains unicode strings and byte strings.
nocaselist 1.1.0
Released: 2023-01-21
Incompatible changes:
The default casefolding method on Python 3 was changed from str.lower() to str.casefold(). This changes the matching of the case-insensitive values. This shold normally be an improvement, but in case you find that you are negatively affected by this change, you can go back to the str.lower() method by overriding the NocaseDict.__casefold__() method with a method that calls str.lower(). (issue #95)
Enhancements:
Added support for Python 3.11.
Changed the default casefolding method on Python 3 to be str.casefold() in order to improve Unicode support. On Python 2, it remains str.lower(). Added support for user-defined casefolding. (issue #95)
Added support for storing None as a value in a NocaseList. Previously, that was rejected with AttributeError since the casefold method was attempted to be called on the None value. (part of issue #95)
nocaselist 1.0.6
Released: 2022-08-04
Bug fixes:
Various fixes in dependencies and test environment.
nocaselist 1.0.5
Released: 2022-03-27
Bug fixes:
Mitigated the coveralls HTTP status 422 by pinning coveralls-python to <3.0.0 (issue #55).
Fixed a dependency error that caused importlib-metadata to be installed on Python 3.8, while it is included in the Python base.
Fixed new issues raised by Pylint 2.10.
Disabled new Pylint issue ‘consider-using-f-string’, since f-strings were introduced only in Python 3.6.
Fixed install error of wrapt 1.13.0 on Python 2.7 on Windows due to lack of MS Visual C++ 9.0 on GitHub Actions, by pinning it to <1.13.
Fixed TypeError when running Sphinx due to using docutils 0.18 on Python 2.7.
Fixed error when installing virtualenv in install test on Python 2.7.
Fixed that the added setup.py commands (test, leaktest, installtest) were not displayed. They are now displayed at verbosity level 1 (using ‘-v’).
Enhancements:
Enhanced test matrix on GitHub Actions to always include Python 2.7 and Python 3.4 on Ubuntu and Windows, and Python 2.7 and Python 3.5 on macOS.
Support for Python 3.10: Added Python 3.10 in GitHub Actions tests, and in package metadata.
Cleanup:
Removed old tools that were needed on Travis and Appveyor but no longer on GitHub Actions: remove_duplicate_setuptools.py, retry.bat
nocaselist 1.0.4
Released: 2021-01-01
Enhancements:
Migrated from Travis and Appveyor to GitHub Actions. This required changes in several areas including dependent packages used for testing and coverage. This did not cause any changes on dependent packages used for the installation of the package.
nocaselist 1.0.3
Released: 2020-10-04
Bug fixes:
Test: Fixed issue with virtualenv raising AttributeError during installtest on Python 3.4. (see issue #43)
Added checking for no expected warning. Adjusted a testcase to accomodate the new check. (see issue #45)
nocaselist 1.0.2
Released: 2020-09-11
Bug fixes:
Fixed an AttributeError during unpickling. (See issue #37)
Enhancements:
Optimized pickling a NocaseList object by serializing only the original list, but not the second lower-cased list. This optimization is only implemented for Python 3.
Added tests for pickling and unpickling.
Cleanup:
Suppressed new Pylint issue ‘super-with-arguments’, because this package still supports Python 2.7.
nocaselist 1.0.1
Released: 2020-07-28
Bug fixes:
Fixed the incorrect behavior of the ‘+’ and ‘+=’ operators to now (correctly) treat the right hand operand as an iterable of items to be added, instead of (incorrectly) as a single item. For ‘+’, the right hand operand now must be a list, consistent with the built-in list class. (See issue #25)
Fixed the incorrect behavior of the * and *= operators to now validate that the number is an integer and raise TypeError otherwise, consistent with the built-in list class. (See issue #27)
Enhancements:
Removed enforcement of Python version at run time. (See issue #18)
Added support for the clear() method on Python 2.7 (where the built-in list class does not support it yet). (See issue #30)
The *= operator now modifies the left hand operand list in place, instead of returning a new list. Note that both is correct behavior. (Part of issue #27)
Improved the performance of initializing a NocaseList object by copying the internal lower-cased list when possible, instead of rebuilding it from the original list.
Test: Coveralls now runs on all python versions, merging the result. (See issue #17)
Test: Added support for testing against standard list, by adding a new make target ‘testlist’, and running that test on the Travis and Appveyor CIs. (See issue #16)
Docs: Clarified that NocaseList supports the functionality of the built-in list class as of Python 3.8, including all methods that have been added since Python 2.7, on all Python versions.
Docs: Documented exceptions that can be raised, in all methods.
Docs: Switched Sphinx theme to sphinx_rtd_theme (See issue #19)
Docs: Switched links to items in the Python documentation to go to Python 3 instead of Python 2.
nocaselist 1.0.0
Released: 2020-07-21
Initial release.