Skip to content

Commit

Permalink
Merge pull request #9 from ChieloNewctle/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ChieloNewctle authored Dec 16, 2023
2 parents d051727 + 7018a78 commit 984793a
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 7 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ jobs:
name: release
url: https://pypi.org/p/plain-abc
permissions:
contents: write
id-token: write
steps:
- name: Download all the dists
Expand All @@ -98,3 +99,18 @@ jobs:
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,6 @@ dmypy.json

# IDE
.vscode

# pytest-readme
tests/test_readme.py
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Chielo
Copyright (c) 2023 Chielo Newctle <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Another `ABC` implementation without `metaclass`.

It is a little bit annoying to have metaclass conflict,
It is a little bit annoying to have `metaclass` conflict,
especially when trying to use ABC along with other libraries.

`plain-abc` provides a simple `ABC` implementation without `metaclass`.
Expand Down Expand Up @@ -94,10 +94,10 @@ class Foo(IEnum, Enum):
assert Foo.foo.value == 'foo'
```

## To solve metaclass conflict without `plain-abc`
## To solve `metaclass` conflict without `plain-abc`

Here is an example of metaclass conflict
and how to mix ABCMeta and other metaclasses.
Here is an example of `metaclass` conflict
and how to mix `ABCMeta` with other `metaclass`es.

```python
from abc import ABC, ABCMeta, abstractmethod
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "plain-abc"
version = "0.0.4"
authors = [{ name = "Chielo Newctle", email = "ChieloNewctle@Yandex.com" }]
version = "0.1.0"
authors = [{ name = "Chielo Newctle", email = "ChieloNewctle@gmail.com" }]
description = "An ABC implementation without metaclass"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
53 changes: 53 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
def parse_from_readme():
"""
Adapted from https://github.com/boxed/pytest-readme
Copyright (c) 2020, Anders Hovmöller
Under the BSD 3-Clause "New" or "Revised" License.
"""
with open(
"tests/test_readme.py",
"w",
encoding="utf8",
) as out, open("README.md", encoding="utf8") as readme:
output, mode = [], None

for i, line in enumerate(readme.readlines()):
output.append("\n")

if mode is None and line.strip() == "```python":
mode = "first_line"
output[i] = "def test_line_%s():\n" % i
continue

if line.strip() == "```":
if mode == "doctest":
output[i] = ' """\n'
mode = None
continue

if mode == "first_line":
if line.strip() == "":
mode = None
output[i - 1] = "\n"
continue

if line.strip().startswith(">>>"):
mode = "doctest"
output[i - 2] = (
output[i - 1][:-1] + " " + output[i - 2]
) # move the def line one line up
output[i - 1] = ' """\n'
else:
mode = "test"

if mode in ("doctest", "test"):
output[i] = " " + line
else:
output[i] = "# %s" % line

out.writelines(output)


parse_from_readme()

0 comments on commit 984793a

Please sign in to comment.