Skip to content

Commit

Permalink
Update CI to Python-3.12 (#22)
Browse files Browse the repository at this point in the history
* Update python versions and doc dependencies

* Moved from Travis to GitHub actions

* RTD build config update for py3.9+

* marked escaped strings as raw for docs
  • Loading branch information
chrizzFTD authored Apr 14, 2024
1 parent a7cf42c commit f6b3eff
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 118 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python CI
on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install
run: |
python -m pip install --upgrade pip
python -m pip install pytest pytest-cov codecov
python -m pip install .
- name: Test
run: |
pytest --cov=./ --cov-report xml
codecov
- name: Codecov Report
uses: codecov/codecov-action@v3
17 changes: 13 additions & 4 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
version: 2 # required for PY39+
build:
os: ubuntu-20.04
tools:
python: "3.12"
apt_packages:
- "graphviz"

python:
version: 3.7
pip_install: true
extra_requirements:
- docs
install:
- method: pip
path: .
extra_requirements:
- docs
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
[![PyPI version](https://badge.fury.io/py/naming.svg)](https://badge.fury.io/py/naming)
[![PyPI](https://img.shields.io/pypi/pyversions/naming.svg)](https://pypi.python.org/pypi/naming)

Object-oriented names for the digital era.
> Object-oriented names for the digital era.
`naming` provides an interface for dealing with naming conventions; from
defining them, to identifying names and creating new ones.

### Installation
## Installation

`naming` is available for Python 3.7 onwards via PyPI.
`naming` is available for Python 3.8+ via PyPI.

```bash
$ pip install naming
```

### Usage
## Example

Please refer to the [documentation](http://naming.readthedocs.io/en/latest/) for details on contents and usage.
Please refer to the [documentation walkthrough](http://naming.readthedocs.io/en/latest/) for details on contents and usage.

```python
>>> import naming
Expand Down
20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

36 changes: 0 additions & 36 deletions docs/make.bat

This file was deleted.

8 changes: 4 additions & 4 deletions docs/source/build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from pathlib import Path
from sphinx.cmd import build

source_path = Path(__file__).parent
build_path = source_path.parent / "build"
source_root = Path(__file__).parent
build_root = source_root.parent / "build"
try:
shutil.rmtree(build_path)
shutil.rmtree(build_root)
except FileNotFoundError:
pass
build.build_main([str(source_path), str(build_path)])
build.build_main([str(source_root), str(build_root)])
67 changes: 37 additions & 30 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))

from datetime import datetime

# -- General configuration ------------------------------------------------

Expand All @@ -31,25 +31,38 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
# namingpath = r'B:\write\code\git\naming'
# import sys
# sys.path.append(namingpath)
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'sphinx.ext.graphviz',
'sphinx_copybutton',
'sphinx_toggleprompt',
'sphinx.ext.inheritance_diagram',
'sphinx_autodoc_typehints']

# graphviz_dot = r'B:\__appdata__\graphviz\bin\dot.exe'
extensions = [
'hoverxref.extension',
'myst_parser',
'sphinx.ext.autodoc',
'sphinx.ext.autosectionlabel',
'sphinx.ext.coverage',
'sphinx.ext.doctest',
'sphinx.ext.graphviz',
'sphinx.ext.intersphinx',
'sphinx.ext.inheritance_diagram',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'sphinx_autodoc_typehints',
'sphinx_copybutton',
'sphinx_togglebutton',
'sphinx_toggleprompt',
]

# Offset to play well with copybutton
toggleprompt_offset_right = 25
toggleprompt_offset_right = 35
togglebutton_hint = " "
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
}
hoverxref_auto_ref = True
hoverxref_default_type = 'tooltip'

hoverxref_intersphinx = list(set(intersphinx_mapping) - {'python'})
hoverxref_intersphinx_types = dict.fromkeys(intersphinx_mapping, hoverxref_default_type)
hoverxref_domains = ['py']

always_document_param_types = True

inheritance_graph_attrs = dict(bgcolor='transparent')
graphviz_output_format = 'svg'
Expand All @@ -64,7 +77,7 @@


# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
Expand All @@ -76,24 +89,24 @@

# General information about the project.
project = 'naming'
copyright = '2017, Christian López Barrón'
copyright = f'{datetime.now().year}, Christian López Barrón'
author = 'Christian López Barrón'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.3'
version = '0.7'
# The full version, including alpha/beta/rc tags.
release = '0.3.1'
release = '0.7.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -143,7 +156,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# html_static_path = ['_static']


# -- Options for HTMLHelp output ------------------------------------------
Expand Down Expand Up @@ -201,9 +214,3 @@
author, 'naming', 'One line description of project.',
'Miscellaneous'),
]




# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/3': None}
11 changes: 3 additions & 8 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to naming's documentation!
==================================
.. include:: ../../README.md
:parser: myst_parser.sphinx_

.. toctree::
:maxdepth: 2
:caption: Contents:

Overview
Class List

Indices and tables
==================

* :ref:`genindex`
* :ref:`search`
genindex
16 changes: 8 additions & 8 deletions naming/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Name(_BaseName):
Example:
>>> from naming import Name
>>> class MyName(Name):
... config = dict(base=r'\w+')
... config = dict(base=r'\\w+')
...
>>> n = MyName()
>>> n.get() # no name has been set on the object, convention is solved with {missing} fields
Expand Down Expand Up @@ -64,7 +64,7 @@ class File(_BaseName):
Example:
>>> from naming import File
>>> class MyFile(File):
... config = dict(base=r'\w+')
... config = dict(base=r'\\w+')
...
>>> f = MyFile()
>>> f.get()
Expand All @@ -82,7 +82,7 @@ class File(_BaseName):
>>> f.path
WindowsPath('hello.abc')
"""
file_config = NameConfig(dict(suffix='\w+'))
file_config = NameConfig(dict(suffix=r'\w+'))

@property
def _pattern(self) -> str:
Expand Down Expand Up @@ -139,14 +139,14 @@ class Pipe(_BaseName):
====== ============
**Composed Fields**
--------------------
*pipe* Combination of unique fields in the form of: (.{output})\*.{version}.{index}**
\* optional field. ** exists only when *output* is there as well.
*pipe* Combination of unique fields in the form of: (.{output})*.{version}.{index}**
\\* optional field. ** exists only when *output* is there as well.
====================
Example:
>>> from naming import Pipe
>>> class MyPipe(Pipe):
... config = dict(base=r'\w+')
... config = dict(base=r'\\w+')
...
>>> p = MyPipe()
>>> p.get()
Expand Down Expand Up @@ -176,7 +176,7 @@ class Pipe(_BaseName):
>>> p.values
{'base': 'my_wip_data', 'pipe': '.exchange.7.101', 'output': 'exchange', 'version': '7', 'index': '101'}
"""
pipe_config = NameConfig(dict(pipe='\w+', output='\w+', version='\d+', index='\d+'))
pipe_config = NameConfig(dict(pipe=r'\w+', output=r'\w+', version=r'\d+', index=r'\d+'))

@property
def _pattern(self):
Expand Down Expand Up @@ -234,7 +234,7 @@ class PipeFile(File, Pipe):
Example:
>>> from naming import PipeFile
>>> class MyPipeFile(PipeFile):
... config = dict(base=r'\w+')
... config = dict(base=r'\\w+')
...
>>> p = MyPipeFile('wipfile.7.ext')
>>> p.values
Expand Down
2 changes: 1 addition & 1 deletion naming/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def _dct_from_mro(cls: type, attr_name: str) -> dict:
""""Get a merged dictionary from `cls` bases attribute `attr_name`. MRO defines importance (closest = strongest)."""
"""Get a merged dictionary from `cls` bases attribute `attr_name`. MRO defines importance (closest = strongest)."""
d = {}
for c in reversed(cls.mro()):
d.update(getattr(c, attr_name, {}))
Expand Down
10 changes: 8 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ keywords = name names naming convention configuration config cfg regex
author_email = [email protected]
author = Christian López Barrón
url = https://github.com/chrizzFTD/naming
# Try to align to https://devguide.python.org/versions/
classifiers =
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12

[options]
packages = find:

[options.extras_require]
docs = sphinx_autodoc_typehints; sphinx_rtd_theme; sphinx-toggleprompt; sphinx-copybutton;
# docs dependencies install:
# conda install --channel conda-forge pygraphviz
# python -m pip install sphinx myst-parser sphinx-toggleprompt sphinx-copybutton sphinx-togglebutton sphinx-hoverxref sphinx_autodoc_typehints sphinx_rtd_theme
docs = sphinx; myst-parser; sphinx-toggleprompt; sphinx-copybutton; sphinx-togglebutton; sphinx-hoverxref; sphinx_autodoc_typehints; sphinx_rtd_theme
File renamed without changes.

0 comments on commit f6b3eff

Please sign in to comment.