Giter VIP home page Giter VIP logo

Comments (3)

bswck avatar bswck commented on August 17, 2024 1

Indeed, it passes! That's why I said #102 preserves the behavior of handling multiple assignments, and does not alter it.
I saw a missing test rather as a coverage issue, not an undefined behavior.

Looking at

pip-run/pip_run/scripts.py

Lines 169 to 176 in 966d86b

(node,) = (
node
for node in mod.body
if isinstance(node, ast.Assign)
and len(node.targets) == 1
and isinstance(node.targets[0], ast.Name)
and node.targets[0].id == var_name
)

if we try to unpack multiple (or no) nodes in place where one is expected (node,) a value error is raised.

Which is why maybe it's a better idea to actually make _read safe and precisely describe the cases it supports? This is what #102 tried to do, but at the cost of expanding the implementation to imperative approach.

The callee of that function just so happened to suppress ValueError, so that's why I thought the concern was addressed since the beginning.

from pip-run.

jaraco avatar jaraco commented on August 17, 2024

Also, I'll want to test to confirm what is the current behavior.

The following test passes, so the current behavior is to silently ignore both:

diff --git a/tests/test_scripts.py b/tests/test_scripts.py
index 877c0a5..0326b4c 100644
--- a/tests/test_scripts.py
+++ b/tests/test_scripts.py
@@ -56,6 +56,15 @@ class TestSourceDepsReader:
         )
         assert scripts.DepsReader(script).read() == ['foo']
 
+    def test_duplicate_definition(self):
+        script = textwrap.dedent(
+            """
+            __requires__=['foo']
+            __requires__=['bar']
+            """
+        )
+        assert scripts.DepsReader(script).read() == []
+
     def test_reads_files_with_multiple_assignment(self):
         script = textwrap.dedent(
             """

from pip-run.

jaraco avatar jaraco commented on August 17, 2024

I've gone ahead and pushed that test, making it an explicitly-tested expectation.

Indeed, it passes! That's why I said #102 preserves the behavior of handling multiple assignments, and does not alter it.
I saw a missing test rather as a coverage issue, not an undefined behavior.

Thanks. Yeah, that was my mis-read on the intention there.

from pip-run.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.