Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interpreter: Introduce StringHolder #9207

Merged
merged 3 commits into from
Sep 25, 2021
Merged

Conversation

mensinda
Copy link
Member

@mensinda mensinda commented Sep 1, 2021

Another commit in my quest to rid InterpreterBase from all higher
level object processing logic.

Additionally, there is a a logic change here, since str.join now
uses varargs and can now accept more than one argument (and supports
list flattening).

@mensinda mensinda added the refactoring No behavior changes label Sep 1, 2021
@lgtm-com
Copy link

lgtm-com bot commented Sep 1, 2021

This pull request introduces 1 alert when merging ff38350 into d67850b - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Sep 1, 2021

This pull request introduces 2 alerts when merging 77fcf43 into d67850b - view on LGTM.com

new alerts:

  • 2 for Unused import

@codecov
Copy link

codecov bot commented Sep 1, 2021

Codecov Report

Merging #9207 (829ee89) into master (64c267c) will increase coverage by 0.03%.
The diff coverage is 88.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9207      +/-   ##
==========================================
+ Coverage   66.88%   66.91%   +0.03%     
==========================================
  Files         386      388       +2     
  Lines       85171    85199      +28     
  Branches    17559    17497      -62     
==========================================
+ Hits        56966    57015      +49     
- Misses      23431    23452      +21     
+ Partials     4774     4732      -42     
Impacted Files Coverage Δ
mesonbuild/interpreter/__init__.py 100.00% <ø> (ø)
mesonbuild/interpreterbase/decorators.py 89.64% <0.00%> (-1.02%) ⬇️
mesonbuild/build.py 76.70% <50.00%> (-0.03%) ⬇️
mesonbuild/interpreterbase/interpreterbase.py 68.09% <66.66%> (-2.56%) ⬇️
mesonbuild/interpreter/interpreterobjects.py 85.47% <75.00%> (+0.04%) ⬆️
mesonbuild/interpreterbase/baseobjects.py 77.08% <75.00%> (+0.99%) ⬆️
mesonbuild/interpreter/primitives/string.py 98.13% <98.13%> (ø)
mesonbuild/ast/interpreter.py 80.46% <100.00%> (+0.07%) ⬆️
mesonbuild/interpreter/interpreter.py 82.25% <100.00%> (ø)
mesonbuild/interpreter/mesonmain.py 95.35% <100.00%> (+0.01%) ⬆️
... and 23 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64c267c...829ee89. Read the comment docs.

@mensinda mensinda force-pushed the strHolder branch 2 times, most recently from 3735e0a to 802c4a2 Compare September 2, 2021 18:41
@lgtm-com
Copy link

lgtm-com bot commented Sep 2, 2021

This pull request fixes 2 alerts when merging 802c4a2 into 1dbb6d6 - view on LGTM.com

fixed alerts:

  • 2 for Non-standard exception raised in special method

@eli-schwartz
Copy link
Member

Additionally, there is a a logic change here, since str.join now uses varargs and can now accept more than one argument (and supports list flattening).

I don't see a FeatureNew for this.

@mensinda
Copy link
Member Author

I don't see a FeatureNew for this.

That's because there is no way to check for this after the refactoring. @typed_pos_args('str.join', varargs=str) does the conversion and there is no way to get to the original value. Additionally, methods don't know about the original Function node, so there is also no way to do that check on the AST level...

@mensinda
Copy link
Member Author

Nevermind, I forgot that the InterpreterObjects also store the current node. It's not pretty, but it works.

@lgtm-com
Copy link

lgtm-com bot commented Sep 12, 2021

This pull request fixes 2 alerts when merging 47cc82d into f291b63 - view on LGTM.com

fixed alerts:

  • 2 for Non-standard exception raised in special method

@mensinda
Copy link
Member Author

ping

Copy link
Member

@dcbaker dcbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one small style nit, otherwise this looks great to me. I'm happy to not see the v2, my reviewed-by stands.

mesonbuild/interpreter/primitives/string.py Outdated Show resolved Hide resolved
@jpakkane
Copy link
Member

⚔️ conflicts.

Another commit in my quest to rid InterpreterBase from all higher
level object processing logic.

Additionally, there is a a logic change here, since `str.join` now
uses varargs and can now accept more than one argument (and supports
list flattening).
@lgtm-com
Copy link

lgtm-com bot commented Sep 25, 2021

This pull request fixes 2 alerts when merging 829ee89 into 64c267c - view on LGTM.com

fixed alerts:

  • 2 for Non-standard exception raised in special method

@mensinda mensinda merged commit c0efa7a into mesonbuild:master Sep 25, 2021
@mensinda mensinda deleted the strHolder branch September 25, 2021 10:44
# Implement some basic FeatureNew check on the AST level
assert isinstance(self.current_node, MethodNode)
n_args = self.current_node.args.arguments
if len(n_args) != 1 or not isinstance(n_args[0], ArrayNode) or not all(isinstance(x, StringNode) for x in n_args[0].args.arguments):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just accidentally created a case where this is triggering:

https://github.com/mesonbuild/wrapdb/pull/176/files#diff-8c713a7313f3f36bd6f36590315691da5d03b76273f019ad09cd8dfcbbb8a3f1R6

Apparently this is an IndexNode instead of a StringNode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is in we need an issue we can attach to the 0.60 milestone so we don't accidentally release with this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mensinda Thoughts on fixing this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... This looks like it's going to be a huge pain. The only real way of fixing I can think of is to call evaluate_statement again on the nodes to check the type. But then this will break: ', '.join([run_command('./must_only_be_called_once.sh').stdout()]).

I really don't know how to properly implement this check then... Would it be ok to completely remove it or has someone a better idea?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are right on top of rc1 and no one has proposed a better idea, let's remove it. #9382

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring No behavior changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants