Skip to content

Commit 72f0525

Browse files
committed
Merge fix/implicit-class-reference into master
2 parents 96b90d5 + 03f6989 commit 72f0525

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

changelog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,20 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.0] - 2023-01-20
9+
### Fixed
10+
11+
- `md.python.reference` class implicit reference resolution issue:
12+
returns class definition parent type, instead of itself.
13+
14+
### Changed
15+
16+
- documentation enhancement:
17+
- clarified component packages on architecture class diagram
18+
819
## [1.0.0] - 2023-01-19
920

1021
- Initial implementation
1122

23+
[1.1.0]: https://github.com/md-py/md.python/releases/tag/1.1.0
1224
[1.0.0]: https://github.com/md-py/md.python/releases/tag/1.0.0

lib/md/python/_python.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ def reference(definition: typing.Union[str, collections.Callable], explicit: boo
134134
if module_reference == 'builtins':
135135
return definition.__name__ # e.g. reference(str) -> 'str'
136136

137+
if isinstance(definition, type):
138+
return f'{module_reference}.{definition.__name__}'
139+
137140
return definition.__class__.__name__ # as is
138141

139142

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name='md.python',
8-
version='1.0.0',
8+
version='1.1.0',
99
description='component that provides python definition API',
1010
long_description=long_description,
1111
long_description_content_type='text/markdown',

tests/acceptance/python.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ def test_reference_explicit(self) -> None: # white/positive
3333
# assert
3434
assert reference_ == 'md.python._python.reference'
3535

36+
def test_reference_implicit_class(self) -> None: # white/positive
37+
# act
38+
reference_ = md.python.reference(definition=TestReference, explicit=False)
39+
40+
# assert
41+
assert reference_ == 'python.TestReference'
42+
3643
def test_reference_implicit(self) -> None: # white/positive
3744
# act
3845
reference_ = md.python.reference(definition=md.python.reference, explicit=False)

0 commit comments

Comments
 (0)