Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 9dfd1b1

Browse files
committed
tag: str | None -> str
add Asset.from_tag fix import error in setup.py
1 parent 6eafe0a commit 9dfd1b1

File tree

10 files changed

+22
-10
lines changed

10 files changed

+22
-10
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
- name: Install dependencies
2525
run: |
2626
python -m pip install --upgrade pip pytest
27-
export PYTHONPATH=$(pwd)/src
2827
python -m pip install -e .[async]
2928
3029
- name: Test with pytest

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include src/updater/VERSION

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ pip install AssetsUpdater[async]@https://github.com/JamzumSum/AssetsUpdater.git
3232

3333
Python type annotation is fully supported.
3434

35+
<details>
36+
3537
**Updater**
3638

3739
> Only GitHub updater is implemented now.
@@ -53,6 +55,9 @@ Python type annotation is fully supported.
5355
`Asset` has:
5456
- name
5557
- download_url
58+
- from_tag
59+
60+
</details>
5661

5762
## API and Examples
5863

@@ -94,7 +99,7 @@ Python type annotation is fully supported.
9499
> from updater.github import GhUpdater, Repo
95100
> up = GhUpdater(Repo(user, reponame))
96101
# try to parse version from release title; skip instead of raise InvalidVersion if a tag doesn't confirm PEP440
97-
> relist = version_filter(up, '0.1.0', num=3, pre=True, try_title=True, skip_legacy=True)
102+
> relist = version_filter(up, '0.0.1', num=3, pre=True, try_title=True, skip_legacy=True)
98103
> list(relist)
99104
[<0.1.2> 0.1.2, <0.1.1> 0.1.1.dev1, <0.1.0> 0.1.0.dev1]
100105
~~~

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from setuptools import find_packages, setup
22

3-
from updater import __version__
3+
with open('src/updater/VERSION') as f:
4+
__version__ = f.read()
45

56
NAME = 'AssetsUpdater'
67
LOWER_NAME = NAME.lower()

src/updater/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.2

src/updater/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
__version__ = '0.1'
1+
from pathlib import Path
2+
with open(Path(__file__).with_name('VERSION')) as f:
3+
__version__ = f.read()

src/updater/github.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ def pre(self) -> bool:
3131
return self.raw['prerelease']
3232

3333
def assets(self):
34-
return [Asset(i['name'], i['browser_download_url']) for i in self.raw['assets']]
34+
return [
35+
Asset(self.tag, i['name'], i['browser_download_url'])
36+
for i in self.raw['assets']
37+
]
3538

3639
@property
3740
def title(self) -> str:
3841
return self.raw['name']
3942

4043
@property
41-
def tag(self) -> Optional[str]:
44+
def tag(self) -> str:
4245
return self.raw.get('tag_name', None)
4346

4447

src/updater/type.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
@dataclass(frozen=True)
99
class Asset:
10+
from_tag: str
1011
name: str
1112
download_url: str
1213

@@ -16,7 +17,7 @@ def __repr__(self) -> str:
1617

1718
class Release(ABC):
1819
@abstractproperty
19-
def tag(self) -> Optional[str]:
20+
def tag(self) -> str:
2021
return ''
2122

2223
@abstractproperty

src/updater/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,3 @@ def name_filter(updater: Updater, pattern: Union[str, re.Pattern], num, pre=Fals
7070
tag_filter,
7171
name_filter,
7272
]]
73-

test/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
def setup_module():
99
global up
10-
up = GhUpdater(Repo('JamzumSum', 'QzEmoji'))
10+
up = GhUpdater(Repo('JamzumSum', 'AssetsUpdater'))
1111

1212

1313
def test_latest_asset():
14-
url = updater.get_latest_asset(up, 'emoji.db')
14+
url = updater.get_latest_asset(up, 'AssetsUpdater-0.1.tar.gz')
1515
assert url.download_url
1616

1717

0 commit comments

Comments
 (0)