#459 Remove usage of mutable default arguments
Merged 4 years ago by qwan. Opened 4 years ago by qwan.
qwan/freshmaker fix-mutable-default-arg  into  master

@@ -467,7 +467,7 @@ 

                                             compose_ids=compose_ids)

  

      @fail_artifact_build_on_handler_exception(whitelist=[ODCSComposeNotReady])

-     def build_image_artifact_build(self, build, repo_urls=[]):

+     def build_image_artifact_build(self, build, repo_urls=None):

          """

          Submits ArtifactBuild of 'image' type to Koji.

  
@@ -531,7 +531,7 @@ 

          # We use repo_urls only in special cases to build base images. In this

          # cases, we want to convert compose_ids to repository URLs. Otherwise,

          # just pass compose_ids to OSBS via Koji.

-         if repo_urls:

+         if repo_urls is not None:

              for compose_id in compose_ids:

                  odcs_compose = self.odcs_get_compose(compose_id)

                  if odcs_compose["state"] in [COMPOSE_STATES['wait'],

file modified
+4 -2
@@ -99,7 +99,7 @@ 

          self.handler = handler

  

      def _fake_odcs_new_compose(

-             self, compose_source, tag, packages=None, results=[],

+             self, compose_source, tag, packages=None, results=None,

              builds=None):

          """

          Fake odcs.new_compose(...) method used in the dry run mode.
@@ -125,8 +125,10 @@ 

          new_compose['result_repofile'] = "http://localhost/%d.repo" % (

              new_compose['id'])

          new_compose['state'] = COMPOSE_STATES['done']

-         if results:

+         if results is None:

              new_compose['results'] = ['boot.iso']

+         else:

+             new_compose['results'] = results

          if builds:

              new_compose['builds'] = builds

  

file modified
+2 -2
@@ -195,7 +195,7 @@ 

          build_container.assert_called_once_with(

              'git://pkgs.fedoraproject.org/repo#hash', 'branch', 'target',

              arch_override='x86_64', compose_ids=[5, 6, 7, 8], isolated=True,

-             koji_parent_build=None, release='2', repo_urls=[])

+             koji_parent_build=None, release='2', repo_urls=None)

  

      @patch("freshmaker.handlers.ContainerBuildHandler.build_container")

      def test_build_image_artifact_build_renewed_odcs_composes(
@@ -210,7 +210,7 @@ 

          build_container.assert_called_once_with(

              'git://pkgs.fedoraproject.org/repo#hash', 'branch', 'target',

              arch_override='x86_64', compose_ids=[5, 6, 7, 8, 7300, 7301],

-             isolated=True, koji_parent_build=None, release='2', repo_urls=[])

+             isolated=True, koji_parent_build=None, release='2', repo_urls=None)

  

      @patch("freshmaker.handlers.ContainerBuildHandler.build_container")

      def test_build_image_artifact_build_repo_urls(

Commit 04a8607 fixes this pull-request

Pull-Request has been merged by qwan

4 years ago

Pull-Request has been merged by qwan

4 years ago