Skip to content

Commit

Permalink
manifest: re-work ManifestProject's fake attributes
Browse files Browse the repository at this point in the history
Change the url, revision, and clone_depth properties to plain old
attributes, changing url from None to the empty string. This will be
used to make it possible to type annotate Project in a subsequent
commit.

This seems like even more evidence that ManifestProject is not a
Project in a subtyping sense, should not have been treated like one,
and should be removed (#327).

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
  • Loading branch information
mbolivar-nordic committed Jun 24, 2020
1 parent 1edc451 commit 1251612
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
33 changes: 7 additions & 26 deletions src/west/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,11 +744,11 @@ class ManifestProject(Project):
Other readable attributes included for Project compatibility:
- ``url``: always ``None``; the west manifest is not
- ``url``: the empty string; the west manifest is not
version-controlled by west itself, even though 'west init'
can fetch a manifest repository from a Git remote
- ``revision``: ``"HEAD"``
- ``clone_depth``: ``None``, because ``url`` is
- ``clone_depth``: ``None``, because there's no URL
'''

def __repr__(self):
Expand All @@ -769,6 +769,11 @@ def __init__(self, path=None, west_commands=None, topdir=None):
'''
self.name = 'manifest'

# Pretending that this is a Project, even though it's not (#327)
self.url = ''
self.revision = 'HEAD'
self.clone_depth = None

# Path related attributes
self.topdir = topdir
self._abspath = None
Expand Down Expand Up @@ -804,30 +809,6 @@ def posixpath(self):
self._posixpath = PurePath(self.abspath).as_posix()
return self._posixpath

@property
def url(self):
return None

@url.setter
def url(self, url):
raise ValueError(url)

@property
def revision(self):
return 'HEAD'

@revision.setter
def revision(self, revision):
raise ValueError(revision)

@property
def clone_depth(self):
return None

@clone_depth.setter
def clone_depth(self, clone_depth):
raise ValueError(clone_depth)

def as_dict(self):
'''Return a representation of this object as a dict, as it would be
parsed from an equivalent YAML manifest.'''
Expand Down
6 changes: 3 additions & 3 deletions tests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def test_manifest_project():
assert mp.topdir is None
assert mp.abspath is None
assert mp.posixpath is None
assert mp.url is None
assert mp.url == ''
assert mp.revision == 'HEAD'
assert mp.clone_depth is None

Expand All @@ -555,7 +555,7 @@ def test_manifest_project():
assert mp.topdir is None
assert mp.abspath is None
assert mp.posixpath is None
assert mp.url is None
assert mp.url == ''
assert mp.revision == 'HEAD'
assert mp.clone_depth is None

Expand All @@ -577,7 +577,7 @@ def test_manifest_project():
assert PurePath(nodrive(mp.abspath)) == PurePath('/west_top/my-path')
assert mp.posixpath is not None
assert mp.west_commands == ['cmds.yml']
assert mp.url is None
assert mp.url == ''
assert mp.revision == 'HEAD'
assert mp.clone_depth is None

Expand Down

0 comments on commit 1251612

Please sign in to comment.