fraction-py 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. fraction_py-1.0.0/.github/workflows/publish.yml +84 -0
  2. fraction_py-1.0.0/.github/workflows/tests.yml +90 -0
  3. fraction_py-1.0.0/CHANGELOG.md +140 -0
  4. fraction_py-1.0.0/CODE_OF_CONDUCT.md +171 -0
  5. fraction_py-1.0.0/CONTRIBUTING.md +368 -0
  6. fraction_py-1.0.0/LICENSE +21 -0
  7. fraction_py-1.0.0/MANIFEST.in +47 -0
  8. fraction_py-1.0.0/PKG-INFO +1628 -0
  9. fraction_py-1.0.0/README.md +1586 -0
  10. fraction_py-1.0.0/SECURITY.md +154 -0
  11. fraction_py-1.0.0/docs/api.md +386 -0
  12. fraction_py-1.0.0/docs/changelog.md +113 -0
  13. fraction_py-1.0.0/docs/examples.md +391 -0
  14. fraction_py-1.0.0/docs/index.md +216 -0
  15. fraction_py-1.0.0/docs/installation.md +320 -0
  16. fraction_py-1.0.0/examples/arithmetic.py +146 -0
  17. fraction_py-1.0.0/examples/basic_usage.py +83 -0
  18. fraction_py-1.0.0/examples/comparison.py +158 -0
  19. fraction_py-1.0.0/examples/interoperability.py +182 -0
  20. fraction_py-1.0.0/mkdocs.yml +120 -0
  21. fraction_py-1.0.0/pyproject.toml +187 -0
  22. fraction_py-1.0.0/requirements-dev.txt +41 -0
  23. fraction_py-1.0.0/setup.cfg +58 -0
  24. fraction_py-1.0.0/src/fraction/__init__.py +22 -0
  25. fraction_py-1.0.0/src/fraction/fraction.py +371 -0
  26. fraction_py-1.0.0/src/fraction/py.typed +0 -0
  27. fraction_py-1.0.0/src/fraction_py.egg-info/PKG-INFO +1628 -0
  28. fraction_py-1.0.0/src/fraction_py.egg-info/SOURCES.txt +41 -0
  29. fraction_py-1.0.0/src/fraction_py.egg-info/dependency_links.txt +1 -0
  30. fraction_py-1.0.0/src/fraction_py.egg-info/not-zip-safe +1 -0
  31. fraction_py-1.0.0/src/fraction_py.egg-info/requires.txt +13 -0
  32. fraction_py-1.0.0/src/fraction_py.egg-info/top_level.txt +1 -0
  33. fraction_py-1.0.0/tests/test_arithmetic.py +177 -0
  34. fraction_py-1.0.0/tests/test_comparison.py +218 -0
  35. fraction_py-1.0.0/tests/test_constructor.py +103 -0
  36. fraction_py-1.0.0/tests/test_conversion.py +203 -0
  37. fraction_py-1.0.0/tests/test_edge_cases.py +176 -0
  38. fraction_py-1.0.0/tests/test_hash.py +159 -0
  39. fraction_py-1.0.0/tests/test_power.py +143 -0
  40. fraction_py-1.0.0/tests/test_unary.py +137 -0
  41. fraction_py-1.0.0/tests/test_utilities.py +170 -0
  42. fraction_py-1.0.0/tox.ini +83 -0
@@ -0,0 +1,84 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - published
7
+
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: write
12
+ id-token: write
13
+
14
+ jobs:
15
+ publish:
16
+ name: Build and Publish
17
+ runs-on: ubuntu-latest
18
+
19
+ environment:
20
+ name: pypi
21
+ url: https://pypi.org/p/fraction
22
+
23
+ steps:
24
+ - name: Checkout repository
25
+ uses: actions/checkout@v4
26
+
27
+ - name: Set up Python
28
+ uses: actions/setup-python@v5
29
+ with:
30
+ python-version: "3.12"
31
+
32
+ - name: Upgrade pip
33
+ run: |
34
+ python -m pip install --upgrade pip
35
+
36
+ - name: Install build tools
37
+ run: |
38
+ python -m pip install build twine
39
+
40
+ - name: Build distributions
41
+ run: |
42
+ python -m build
43
+
44
+ - name: Verify distributions
45
+ run: |
46
+ twine check dist/*
47
+
48
+ - name: Upload distribution artifacts
49
+ uses: actions/upload-artifact@v4
50
+ with:
51
+ name: python-package-distributions
52
+ path: dist/
53
+
54
+ - name: Publish to PyPI (Trusted Publishing)
55
+ uses: pypa/gh-action-pypi-publish@release/v1
56
+
57
+ # --------------------------------------------------
58
+ # Fallback (Disabled)
59
+ # Uncomment only if using a PyPI API token instead
60
+ #
61
+ # - name: Publish using API Token
62
+ # uses: pypa/gh-action-pypi-publish@release/v1
63
+ # with:
64
+ # user: __token__
65
+ # password: ${{ secrets.PYPI_API_TOKEN }}
66
+ # --------------------------------------------------
67
+
68
+ - name: Generate checksums
69
+ run: |
70
+ cd dist
71
+ sha256sum * > SHA256SUMS
72
+
73
+ - name: Upload checksums
74
+ uses: actions/upload-artifact@v4
75
+ with:
76
+ name: sha256-checksums
77
+ path: dist/SHA256SUMS
78
+
79
+ - name: Upload release assets
80
+ uses: softprops/action-gh-release@v2
81
+ with:
82
+ files: |
83
+ dist/*
84
+
@@ -0,0 +1,90 @@
1
+ name: Continuous Integration
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - master
8
+
9
+ pull_request:
10
+ branches:
11
+ - main
12
+ - master
13
+
14
+ workflow_dispatch:
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ test:
21
+ name: Python ${{ matrix.python-version }}
22
+ runs-on: ubuntu-latest
23
+
24
+ strategy:
25
+ fail-fast: false
26
+
27
+ matrix:
28
+ python-version:
29
+ - "3.12"
30
+ - "3.13"
31
+
32
+ steps:
33
+ - name: Checkout repository
34
+ uses: actions/checkout@v4
35
+
36
+ - name: Set up Python
37
+ uses: actions/setup-python@v5
38
+ with:
39
+ python-version: ${{ matrix.python-version }}
40
+
41
+ - name: Upgrade pip
42
+ run: |
43
+ python -m pip install --upgrade pip
44
+
45
+ - name: Install project
46
+ run: |
47
+ pip install -e .[dev]
48
+
49
+ - name: Show Python version
50
+ run: |
51
+ python --version
52
+
53
+ - name: Run Ruff
54
+ run: |
55
+ ruff check src tests examples
56
+
57
+ - name: Check formatting with Black
58
+ run: |
59
+ black --check src tests examples
60
+
61
+ - name: Run MyPy
62
+ run: |
63
+ mypy src
64
+
65
+ - name: Run pytest
66
+ run: |
67
+ pytest
68
+
69
+ - name: Build package
70
+ run: |
71
+ python -m build
72
+
73
+ - name: Verify distributions
74
+ run: |
75
+ twine check dist/*
76
+
77
+ - name: Upload distribution artifacts
78
+ uses: actions/upload-artifact@v4
79
+ with:
80
+ name: dist-python-${{ matrix.python-version }}
81
+ path: dist/
82
+
83
+ - name: Upload coverage report
84
+ if: matrix.python-version == '3.12'
85
+ uses: actions/upload-artifact@v4
86
+ with:
87
+ name: coverage-report
88
+ path: |
89
+ coverage.xml
90
+ htmlcov/
@@ -0,0 +1,140 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on **Keep a Changelog** and this project adheres to **Semantic Versioning (SemVer)**.
6
+
7
+ ## [Unreleased]
8
+
9
+ ### Added
10
+
11
+ * Planned support for additional utility methods.
12
+ * Planned performance improvements.
13
+ * Planned documentation enhancements.
14
+ * Planned benchmark suite.
15
+ * Planned serialization utilities.
16
+ * Planned additional interoperability features.
17
+
18
+ ---
19
+
20
+ ## [1.0.0] - 2026-07-27
21
+
22
+ ### Added
23
+
24
+ #### Core Features
25
+
26
+ * Initial public release of the `fraction` package.
27
+ * Immutable rational number implementation.
28
+ * Automatic fraction simplification.
29
+ * Positive denominator normalization.
30
+ * Full integration with Python's `numbers.Rational`.
31
+
32
+ #### Constructors
33
+
34
+ * Standard constructor.
35
+ * `from_string()`
36
+ * `from_float()`
37
+ * `from_decimal()`
38
+
39
+ #### Arithmetic
40
+
41
+ * Addition
42
+ * Subtraction
43
+ * Multiplication
44
+ * Division
45
+ * Reverse arithmetic operators
46
+ * In-place arithmetic operators
47
+ * Integer interoperability
48
+ * Float interoperability
49
+ * Compatibility with `fractions.Fraction`
50
+
51
+ #### Comparison
52
+
53
+ * Equality
54
+ * Less than
55
+ * Less than or equal
56
+ * Greater than
57
+ * Greater than or equal
58
+
59
+ #### Unary Operations
60
+
61
+ * Unary plus
62
+ * Unary minus
63
+ * Absolute value
64
+
65
+ #### Power Operations
66
+
67
+ * Integer powers
68
+ * Negative powers
69
+ * Float powers
70
+
71
+ #### Type Conversion
72
+
73
+ * `float()`
74
+ * `int()`
75
+ * `bool()`
76
+ * `round()`
77
+ * String formatting support
78
+
79
+ #### Utility Methods
80
+
81
+ * `reciprocal()`
82
+ * `mixed()`
83
+ * `to_decimal()`
84
+ * `as_tuple()`
85
+
86
+ #### Python Integration
87
+
88
+ * Hashable implementation.
89
+ * Pickle support.
90
+ * Copy support.
91
+ * Deep copy support.
92
+ * Type annotations (PEP 561).
93
+
94
+ #### Packaging
95
+
96
+ * Modern `src/` project layout.
97
+ * PEP 517 build system.
98
+ * PEP 518 compliance.
99
+ * PEP 621 metadata.
100
+ * PyPI-ready packaging.
101
+ * MkDocs documentation.
102
+ * GitHub Actions CI/CD.
103
+ * Comprehensive pytest test suite.
104
+
105
+ ---
106
+
107
+ ## Versioning Policy
108
+
109
+ This project follows **Semantic Versioning (SemVer)**.
110
+
111
+ * **MAJOR** version when incompatible API changes are introduced.
112
+ * **MINOR** version when functionality is added in a backward-compatible manner.
113
+ * **PATCH** version when backward-compatible bug fixes are released.
114
+
115
+ Examples:
116
+
117
+ * `1.0.0` → Initial stable release
118
+ * `1.1.0` → New features
119
+ * `1.1.1` → Bug fixes
120
+ * `2.0.0` → Breaking changes
121
+
122
+ ---
123
+
124
+ ## Release Process
125
+
126
+ Each release should include:
127
+
128
+ * Updated documentation
129
+ * Updated tests
130
+ * Updated version number
131
+ * Git tag
132
+ * GitHub Release
133
+ * PyPI publication
134
+
135
+ ---
136
+
137
+ ## References
138
+
139
+ * Keep a Changelog: https://keepachangelog.com/
140
+ * Semantic Versioning: https://semver.org/
@@ -0,0 +1,171 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We, as members, contributors, and maintainers, pledge to make participation in our community a harassment-free experience for everyone, regardless of:
6
+
7
+ * Age
8
+ * Body size
9
+ * Visible or invisible disability
10
+ * Ethnicity
11
+ * Sex characteristics
12
+ * Gender identity and expression
13
+ * Level of experience
14
+ * Education
15
+ * Socio-economic status
16
+ * Nationality
17
+ * Personal appearance
18
+ * Race
19
+ * Religion
20
+ * Sexual identity and orientation
21
+
22
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
23
+
24
+ ---
25
+
26
+ # Our Standards
27
+
28
+ Examples of behaviour that contributes to a positive environment include:
29
+
30
+ * Demonstrating empathy and kindness toward others.
31
+ * Being respectful of differing opinions, viewpoints, and experiences.
32
+ * Giving and gracefully accepting constructive feedback.
33
+ * Taking responsibility for mistakes and learning from them.
34
+ * Focusing on what is best for the community.
35
+ * Showing professionalism in public discussions and private communications.
36
+ * Helping new contributors feel welcome.
37
+ * Encouraging respectful collaboration.
38
+
39
+ Examples of unacceptable behaviour include:
40
+
41
+ * Harassment or discriminatory language.
42
+ * Trolling, insulting, or derogatory comments.
43
+ * Personal or political attacks.
44
+ * Public or private harassment.
45
+ * Publishing others' private information without explicit permission.
46
+ * Deliberate intimidation or stalking.
47
+ * Threats of violence.
48
+ * Sexual language or imagery in inappropriate contexts.
49
+ * Any conduct that would reasonably be considered inappropriate in a professional setting.
50
+
51
+ ---
52
+
53
+ # Enforcement Responsibilities
54
+
55
+ Project maintainers are responsible for clarifying and enforcing our standards of acceptable behaviour.
56
+
57
+ Maintainers have the right and responsibility to:
58
+
59
+ * Remove, edit, or reject comments, commits, code, issues, wiki edits, discussions, and pull requests that violate this Code of Conduct.
60
+ * Take appropriate and fair corrective action in response to unacceptable behaviour.
61
+ * Communicate moderation decisions respectfully and transparently whenever possible.
62
+
63
+ ---
64
+
65
+ # Scope
66
+
67
+ This Code of Conduct applies within all project spaces, including but not limited to:
68
+
69
+ * GitHub repositories
70
+ * Issues
71
+ * Pull requests
72
+ * Discussions
73
+ * Documentation
74
+ * Community forums
75
+ * Chat platforms related to the project
76
+ * Public events representing the project
77
+
78
+ It also applies when an individual is officially representing the project in public spaces.
79
+
80
+ Examples include:
81
+
82
+ * Using an official project email address.
83
+ * Posting through official project social media accounts.
84
+ * Acting as an appointed representative at conferences or community events.
85
+
86
+ ---
87
+
88
+ # Reporting Issues
89
+
90
+ If you experience or witness unacceptable behaviour, please report it privately to the project maintainer.
91
+
92
+ For project-related concerns, open a private communication through the repository owner or the contact information provided in the project documentation.
93
+
94
+ Reports will be:
95
+
96
+ * Reviewed promptly.
97
+ * Investigated fairly.
98
+ * Handled confidentially whenever possible.
99
+ * Treated with respect for all involved parties.
100
+
101
+ ---
102
+
103
+ # Enforcement Guidelines
104
+
105
+ Project maintainers may apply the following consequences for behaviour that violates this Code of Conduct.
106
+
107
+ ## 1. Correction
108
+
109
+ **Community Impact**
110
+
111
+ Use of inappropriate language or other behaviour deemed unprofessional or unwelcome.
112
+
113
+ **Consequence**
114
+
115
+ A private, written warning explaining the nature of the violation and why the behaviour was inappropriate.
116
+
117
+ ---
118
+
119
+ ## 2. Warning
120
+
121
+ **Community Impact**
122
+
123
+ A violation through a single incident or repeated inappropriate behaviour.
124
+
125
+ **Consequence**
126
+
127
+ A warning with consequences for continued behaviour. Interaction with the community may be limited for a specified period.
128
+
129
+ ---
130
+
131
+ ## 3. Temporary Ban
132
+
133
+ **Community Impact**
134
+
135
+ A serious violation of community standards.
136
+
137
+ **Consequence**
138
+
139
+ A temporary ban from interacting with the project, including discussions, issues, pull requests, and other community spaces.
140
+
141
+ ---
142
+
143
+ ## 4. Permanent Ban
144
+
145
+ **Community Impact**
146
+
147
+ Demonstrating a pattern of violating community standards or engaging in harassment, discrimination, intimidation, or other severe misconduct.
148
+
149
+ **Consequence**
150
+
151
+ A permanent ban from participation in the project community.
152
+
153
+ ---
154
+
155
+ # Attribution
156
+
157
+ This Code of Conduct is adapted from the **Contributor Covenant**, version **2.1**.
158
+
159
+ Contributor Covenant is available at:
160
+
161
+ https://www.contributor-covenant.org/version/2/1/code_of_conduct/
162
+
163
+ Enforcement guidelines were inspired by the Mozilla Community Participation Guidelines.
164
+
165
+ ---
166
+
167
+ # Commitment
168
+
169
+ By participating in this project, you agree to uphold this Code of Conduct and contribute to a respectful, inclusive, and collaborative environment.
170
+
171
+ Thank you for helping make **Fraction** a welcoming project for everyone.