Skip to content
This repository was archived by the owner on Dec 11, 2024. It is now read-only.

Commit f225b43

Browse files
authored
Minor updates (#36)
* compare with identity instead of equality * document classes * pre-commit autoupdate * fix docstrings for numpydoc validation * added numpydoc validation * rename arguments, reword documentation * bump version
1 parent 66c79bf commit f225b43

31 files changed

+344
-178
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ repos:
4949
- src
5050
pass_filenames: false
5151
- repo: https://github.com/psf/black
52-
rev: 23.12.0
52+
rev: 23.12.1
5353
hooks:
5454
- id: black
5555
args:
@@ -75,7 +75,7 @@ repos:
7575
- src
7676
pass_filenames: false
7777
- repo: https://github.com/pre-commit/mirrors-mypy
78-
rev: v1.7.1
78+
rev: v1.8.0
7979
hooks:
8080
- id: mypy
8181
additional_dependencies:
@@ -98,14 +98,14 @@ repos:
9898
stages:
9999
- manual
100100
- repo: https://github.com/RobertCraigie/pyright-python
101-
rev: v1.1.341
101+
rev: v1.1.342
102102
hooks:
103103
- id: pyright
104104
pass_filenames: false
105105
stages:
106106
- manual
107107
- repo: https://github.com/astral-sh/ruff-pre-commit
108-
rev: v0.1.8
108+
rev: v0.1.9
109109
hooks:
110110
- id: ruff
111111
args:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
- Development
3939
- [codespell](https://github.com/codespell-project/codespell)
4040
- [Nox](https://github.com/wntrblm/nox)
41+
- [numpydoc](https://numpydoc.readthedocs.io/)
4142
- [pre-commit](https://github.com/pre-commit/pre-commit)
4243
- [Ruff](https://github.com/astral-sh/ruff)
4344
- Formatting

noxfile.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ def blacken_docs(session: nox.Session) -> None:
9696

9797
@RELEASE_SESSION_DECORATOR
9898
def build(session: nox.Session) -> None:
99-
"""Run build."""
99+
"""Run build.
100+
101+
Parameters
102+
----------
103+
session : nox.Session
104+
nox Session object
105+
"""
100106
session.install("build", "wheel")
101107

102108
session.run("python3", "-m", "build", "--outdir", f"{DIST_DIRECTORY.name}")
@@ -297,7 +303,13 @@ def sphinx(session: nox.Session) -> None:
297303

298304
@RELEASE_SESSION_DECORATOR
299305
def twine(session: nox.Session) -> None:
300-
"""Run twine."""
306+
"""Run twine.
307+
308+
Parameters
309+
----------
310+
session : nox.Session
311+
nox Session object
312+
"""
301313
session.install("twine")
302314

303315
session.run("twine", "check", f"{DIST_DIRECTORY.name}/*")

pyproject.toml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ requires = [
66

77
[project]
88
name = "package-name-to-install-with"
9-
version = "0.0.4"
9+
version = "0.0.5"
1010
description = "A small example package"
1111
keywords = [
1212
"development",
@@ -73,6 +73,7 @@ all = [
7373
"isort",
7474
"mypy",
7575
"nox",
76+
"numpydoc",
7677
"pre-commit",
7778
"pydocstyle[toml]",
7879
"pylint",
@@ -89,6 +90,7 @@ all = [
8990
dev = [
9091
"codespell",
9192
"nox",
93+
"numpydoc",
9294
"pre-commit",
9395
]
9496
doc = [
@@ -381,3 +383,16 @@ min_confidence = 100
381383
paths = [
382384
"src",
383385
]
386+
387+
[tool.numpydoc_validation]
388+
checks = [
389+
"all",
390+
"GL01",
391+
"ES01",
392+
"PR08",
393+
"PR09",
394+
"RT04",
395+
"RT05",
396+
"SA01",
397+
"EX01",
398+
]

requirements/requirements.dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
codespell
22
nox
3+
numpydoc
34
pre-commit
45
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability

src/module_that_can_be_invoked_from_cli.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
import pydantic
88

9-
import package_name_to_import_with
9+
from package_name_to_import_with import (
10+
BinaryArithmeticOperator,
11+
calculate_results,
12+
solve_simplification,
13+
)
1014

1115

1216
@enum.unique
@@ -18,23 +22,49 @@ class CalculatorType(str, enum.Enum):
1822

1923

2024
class BinaryInputs(pydantic.BaseModel):
21-
"""Define arguments for binary calculator."""
25+
"""Define arguments for binary calculator.
26+
27+
Attributes
28+
----------
29+
calculator_type : typing.Literal[CalculatorType.BINARY]
30+
kind of calculator
31+
first_number : float
32+
first number for the calculation
33+
operator : BinaryArithmeticOperator
34+
arithmetic operator to be used
35+
second_number : float
36+
second number for the calculation
37+
"""
2238

2339
calculator_type: typing.Literal[CalculatorType.BINARY]
2440
first_number: float
25-
operator: package_name_to_import_with.calculator_sub_package.ArithmeticOperator
41+
operator: BinaryArithmeticOperator
2642
second_number: float
2743

2844

2945
class GeneralInputs(pydantic.BaseModel):
30-
"""Define arguments of general calculator."""
46+
"""Define arguments of general calculator.
47+
48+
Attributes
49+
----------
50+
calculator_type : typing.Literal[CalculatorType.GENERAL]
51+
kind of calculator
52+
expression : str
53+
mathematical expression to be evaluated
54+
"""
3155

3256
calculator_type: typing.Literal[CalculatorType.GENERAL]
3357
expression: str
3458

3559

3660
class UserInputs(pydantic.BaseModel):
37-
"""Define sub-commands and arguments of CLI calculator."""
61+
"""Define sub-commands and arguments of CLI calculator.
62+
63+
Attributes
64+
----------
65+
inputs : BinaryInputs | GeneralInputs
66+
inputs for the calculator
67+
"""
3868

3969
inputs: BinaryInputs | GeneralInputs = pydantic.Field(discriminator="calculator_type")
4070

@@ -63,9 +93,7 @@ def capture_user_inputs() -> UserInputs:
6393

6494
binary_parser.add_argument("first_number", type=float, help="first number")
6595
binary_parser.add_argument(
66-
"operator",
67-
type=package_name_to_import_with.calculator_sub_package.ArithmeticOperator,
68-
help="arithmetic operator",
96+
"operator", type=BinaryArithmeticOperator, help="arithmetic operator"
6997
)
7098
binary_parser.add_argument("second_number", type=float, help="second number")
7199

@@ -84,13 +112,13 @@ def console_calculator() -> None:
84112
try:
85113
match user_inputs.inputs.calculator_type:
86114
case CalculatorType.BINARY:
87-
operation_result = package_name_to_import_with.calculate_results(
115+
operation_result = calculate_results(
88116
user_inputs.inputs.first_number, # type: ignore[union-attr]
89117
user_inputs.inputs.operator, # type: ignore[union-attr]
90118
user_inputs.inputs.second_number, # type: ignore[union-attr]
91119
)
92120
case CalculatorType.GENERAL:
93-
operation_result = package_name_to_import_with.solve_simplification(
121+
operation_result = solve_simplification(
94122
user_inputs.inputs.expression # type: ignore[union-attr]
95123
)
96124
case _: # pragma: no cover

src/module_that_can_invoke_gui_from_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def define_gui_layout() -> list[list[pydantic.InstanceOf[PySimpleGUI.Element]]]:
2525
[
2626
PySimpleGUI.Text("Enter operator"),
2727
PySimpleGUI.OptionMenu(
28-
package_name_to_import_with.calculator_sub_package.ArithmeticOperator,
28+
package_name_to_import_with.calculator_sub_package.BinaryArithmeticOperator,
2929
key=OPERATOR_INPUT,
3030
),
3131
],
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
"""Expose selected package contents."""
2-
from .calculator_sub_package import calculate_results
2+
from .calculator_sub_package import BinaryArithmeticOperator, calculate_results
33
from .data_using_module import METADATA
44
from .garbage_collection_module import define_garbage_collection_decorator
55
from .simplify import solve_simplification
66

7-
__all__ = ["calculate_results", "define_garbage_collection_decorator", "solve_simplification"]
7+
__all__ = [
8+
"BinaryArithmeticOperator",
9+
"calculate_results",
10+
"define_garbage_collection_decorator",
11+
"solve_simplification",
12+
]
813
__version__: str = METADATA.Version

src/package_name_to_import_with/calculator_sub_package/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
subtract_numbers,
1111
)
1212
from .wrapper_module import (
13-
ARITHMETIC_OPERATIONS,
14-
ArithmeticExpression,
15-
ArithmeticOperation,
16-
ArithmeticOperator,
13+
BINARY_ARITHMETIC_OPERATIONS,
14+
BinaryArithmeticExpression,
15+
BinaryArithmeticOperation,
16+
BinaryArithmeticOperator,
1717
calculate_results,
1818
)
1919

2020
__all__ = [
21-
"ARITHMETIC_OPERATIONS",
22-
"ArithmeticExpression",
23-
"ArithmeticOperation",
24-
"ArithmeticOperator",
21+
"BINARY_ARITHMETIC_OPERATIONS",
22+
"BinaryArithmeticExpression",
23+
"BinaryArithmeticOperation",
24+
"BinaryArithmeticOperator",
2525
"IdentityElements",
2626
"InverseElements",
2727
"add_numbers",

src/package_name_to_import_with/calculator_sub_package/basics/assumptions/inverses_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_negative(input_number: float) -> float:
2727
Parameters
2828
----------
2929
input_number : float
30-
value of number
30+
number for which additive inverse is required
3131
3232
Returns
3333
-------
@@ -56,7 +56,7 @@ def get_reciprocal(input_number: float) -> float:
5656
Parameters
5757
----------
5858
input_number : float
59-
value of number
59+
number for which multiplicative inverse is required
6060
6161
Returns
6262
-------

0 commit comments

Comments
 (0)