ovld 0.3.4__tar.gz → 0.3.6__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.
ovld-0.3.6/.envrc ADDED
@@ -0,0 +1 @@
1
+ . .venv/bin/activate
@@ -0,0 +1,47 @@
1
+ name: Python package
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ lint:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ['3.12']
15
+ steps:
16
+ - name: Check out the code
17
+ uses: actions/checkout@v3
18
+ - name: Install rye
19
+ uses: eifinger/setup-rye@v4
20
+ - name: Pin Python version
21
+ run: rye pin ${{ matrix.python-version }}
22
+ - name: Sync dependencies
23
+ run: rye sync
24
+ - name: Lint check
25
+ run: rye check
26
+ - name: Check formatting
27
+ run: rye format --check
28
+
29
+ test:
30
+ runs-on: ubuntu-latest
31
+ strategy:
32
+ matrix:
33
+ python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
34
+ steps:
35
+ - name: Check out the code
36
+ uses: actions/checkout@v3
37
+ - name: Install rye
38
+ uses: eifinger/setup-rye@v4
39
+ - name: Pin Python version
40
+ run: rye pin ${{ matrix.python-version }}
41
+ - name: Sync dependencies
42
+ run: rye sync
43
+ - name: Test with pytest
44
+ run: rye run pytest --cov=ovld --cov-report term-missing
45
+ - name: Verify coverage
46
+ if: ${{ matrix.python-version == '3.12' }}
47
+ run: rye run coverage report | tail -1 | egrep "TOTAL +[0-9]+ +0 +100%"
ovld-0.3.6/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ __pycache__
2
+ *.egg-info
3
+ dist/
4
+ .pytest_cache
5
+ .coverage
@@ -0,0 +1 @@
1
+ 3.12.4
@@ -1,20 +1,11 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: ovld
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: Overloading Python functions
5
- Home-page: https://github.com/breuleux/ovld
6
- License: MIT
7
- Author: Olivier Breuleux
8
- Author-email: breuleux@gmail.com
9
- Requires-Python: >=3.8,<4.0
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
- Classifier: Programming Language :: Python :: 3.10
15
- Classifier: Programming Language :: Python :: 3.11
16
- Classifier: Programming Language :: Python :: 3.12
17
- Project-URL: Repository, https://github.com/breuleux/ovld
5
+ Author-email: Olivier Breuleux <breuleux@gmail.com>
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.8
18
9
  Description-Content-Type: text/markdown
19
10
 
20
11
 
@@ -328,4 +319,3 @@ bad([1], [2])
328
319
  The functions on the stack have names like `bad.entry`, `bad.dispatch`, `bad[list, list]` and `bad[*, *]` (`*` stands for `object`), which lets you better understand what happened just from the stack trace.
329
320
 
330
321
  This also means profilers will be able to differentiate between these paths and between variants, even if they share code paths.
331
-
@@ -0,0 +1,41 @@
1
+ [project]
2
+ name = "ovld"
3
+ version = "0.3.6"
4
+ description = "Overloading Python functions"
5
+ authors = [
6
+ { name = "Olivier Breuleux", email = "breuleux@gmail.com" }
7
+ ]
8
+ dependencies = []
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ homepage = "https://github.com/breuleux/ovld"
12
+ repository = "https://github.com/breuleux/ovld"
13
+ requires-python = ">= 3.8"
14
+
15
+ [build-system]
16
+ requires = ["hatchling"]
17
+ build-backend = "hatchling.build"
18
+
19
+ [tool.rye]
20
+ managed = true
21
+ dev-dependencies = [
22
+ "codefind>=0.1.6",
23
+ "pytest>=8.3.2",
24
+ "pytest-cov>=5.0.0",
25
+ ]
26
+
27
+ [tool.hatch.metadata]
28
+ allow-direct-references = true
29
+
30
+ [tool.hatch.build.targets.wheel]
31
+ packages = ["src/ovld"]
32
+
33
+ [tool.ruff]
34
+ line-length = 80
35
+
36
+ [tool.ruff.lint]
37
+ extend-select = ["I"]
38
+ ignore = ["E241", "F722", "E501", "E203", "F811", "F821"]
39
+
40
+ [tool.ruff.lint.per-file-ignores]
41
+ "__init__.py" = ["F401", "F403"]
@@ -0,0 +1,24 @@
1
+ # generated by rye
2
+ # use `rye lock` or `rye sync` to update this lockfile
3
+ #
4
+ # last locked with the following flags:
5
+ # pre: false
6
+ # features: []
7
+ # all-features: false
8
+ # with-sources: false
9
+ # generate-hashes: false
10
+ # universal: false
11
+
12
+ -e file:.
13
+ codefind==0.1.6
14
+ coverage==7.6.0
15
+ # via pytest-cov
16
+ iniconfig==2.0.0
17
+ # via pytest
18
+ packaging==24.1
19
+ # via pytest
20
+ pluggy==1.5.0
21
+ # via pytest
22
+ pytest==8.3.2
23
+ # via pytest-cov
24
+ pytest-cov==5.0.0
@@ -0,0 +1,12 @@
1
+ # generated by rye
2
+ # use `rye lock` or `rye sync` to update this lockfile
3
+ #
4
+ # last locked with the following flags:
5
+ # pre: false
6
+ # features: []
7
+ # all-features: false
8
+ # with-sources: false
9
+ # generate-hashes: false
10
+ # universal: false
11
+
12
+ -e file:.
@@ -8,10 +8,15 @@ import typing
8
8
  from types import FunctionType
9
9
 
10
10
  try:
11
- from types import GenericAlias, UnionType
11
+ from types import UnionType
12
12
  except ImportError: # pragma: no cover
13
13
  UnionType = None
14
14
 
15
+
16
+ try:
17
+ from types import GenericAlias
18
+ except ImportError: # pragma: no cover
19
+
15
20
  class GenericAliasMC(type):
16
21
  def __instancecheck__(cls, obj):
17
22
  return hasattr(obj, "__origin__")
@@ -0,0 +1 @@
1
+ version = "0.3.6"
File without changes
@@ -0,0 +1,3 @@
1
+ class House:
2
+ def yummy(self):
3
+ return True
@@ -0,0 +1,52 @@
1
+ from ovld import ovld, ovld_dispatch
2
+
3
+ _ovld_exc = None
4
+ try:
5
+
6
+ @ovld
7
+ def pluralize(x: int):
8
+ return x + 1
9
+
10
+ @ovld
11
+ def pluralize(x: str):
12
+ return x + "s"
13
+
14
+ except Exception as exc:
15
+ _ovld_exc = exc
16
+
17
+
18
+ _ovld_dispatch_exc = None
19
+ try:
20
+
21
+ @ovld_dispatch
22
+ def roesti(self, x):
23
+ return self.resolve(x, x)(x, x)
24
+
25
+ @ovld
26
+ def roesti(self, x: int, y: int):
27
+ return x * y
28
+
29
+ @ovld
30
+ def roesti(self, x: str, y: str):
31
+ return x + y
32
+
33
+ @ovld
34
+ def roesti(self, xs: list, _):
35
+ return [self(x) for x in xs]
36
+
37
+ except Exception as exc:
38
+ _ovld_dispatch_exc = exc
39
+
40
+
41
+ def test_global_ovld():
42
+ if _ovld_exc:
43
+ raise _ovld_exc
44
+ assert pluralize(10) == 11
45
+ assert pluralize("alouette") == "alouettes"
46
+
47
+
48
+ def test_global_ovld_dispatch():
49
+ if _ovld_dispatch_exc:
50
+ raise _ovld_dispatch_exc
51
+ assert roesti(10) == 100
52
+ assert roesti("alouette") == "alouettealouette"