Skip to content

Commit bdff557

Browse files
author
Adam Hrbac
committed
Style changes from PR feedback
1 parent d8a890f commit bdff557

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ContextvarsModuleBuiltins.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
5050
import com.oracle.graal.python.builtins.PythonBuiltins;
5151
import com.oracle.graal.python.builtins.objects.PNone;
52-
import com.oracle.graal.python.builtins.objects.contextvars.PContextVarsContext;
5352
import com.oracle.graal.python.builtins.objects.contextvars.PContextVar;
53+
import com.oracle.graal.python.builtins.objects.contextvars.PContextVarsContext;
5454
import com.oracle.graal.python.nodes.ErrorMessages;
5555
import com.oracle.graal.python.nodes.PRaiseNode;
5656
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
@@ -112,7 +112,8 @@ Object construct(VirtualFrame frame, Object cls) {
112112
@GenerateNodeFactory
113113
public abstract static class TokenNode extends PythonUnaryBuiltinNode {
114114
@Specialization
115-
Object construct(VirtualFrame frame, Object cls, @Cached PRaiseNode raise) {
115+
Object construct(VirtualFrame frame, Object cls,
116+
@Cached PRaiseNode raise) {
116117
throw raise.raise(PythonBuiltinClassType.RuntimeError, ErrorMessages.TOKEN_ONLY_BY_CONTEXTVAR);
117118
}
118119
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextBuiltins.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,18 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
7474
@GenerateNodeFactory
7575
public abstract static class GetContextVar extends PythonBinaryBuiltinNode {
7676
@Specialization
77-
Object get(PContextVarsContext self, Object key, @Cached PRaiseNode raise) {
77+
Object get(PContextVarsContext self, Object key,
78+
@Cached PRaiseNode raise) {
7879
return getContextVar(self, key, null, raise);
7980
}
8081
}
8182

82-
@Builtin(name = "run", takesVarArgs = true, takesVarKeywordArgs = true, minNumOfPositionalArgs = 2, parameterNames = {"$self", "..."})
83+
@Builtin(name = "run", takesVarArgs = true, takesVarKeywordArgs = true, minNumOfPositionalArgs = 2, parameterNames = {"$self", "$callable"})
8384
@GenerateNodeFactory
8485
public abstract static class Run extends PythonBuiltinNode {
8586
@Specialization
86-
Object get(VirtualFrame frame, PContextVarsContext self, Object fun, Object[] args, PKeyword[] keywords, @Cached CallNode call) {
87+
Object get(VirtualFrame frame, PContextVarsContext self, Object fun, Object[] args, PKeyword[] keywords,
88+
@Cached CallNode call) {
8789
PythonContext.PythonThreadState threadState = getContext().getThreadState(getLanguage());
8890
self.enter(threadState);
8991
try {
@@ -109,24 +111,27 @@ Object doCopy(PContextVarsContext self) {
109111
@GenerateNodeFactory
110112
public abstract static class GetMethod extends PythonBuiltinNode {
111113
@Specialization(guards = "isNoValue(def)")
112-
Object doGet(PContextVarsContext self, Object key, Object def, @Cached PRaiseNode raise) {
114+
Object doGet(PContextVarsContext self, Object key, Object def,
115+
@Cached PRaiseNode raise) {
113116
return doGetDefault(self, key, PNone.NONE, raise);
114117
}
115118

116119
@Specialization(guards = "!isNoValue(def)")
117-
Object doGetDefault(PContextVarsContext self, Object key, Object def, @Cached PRaiseNode raise) {
120+
Object doGetDefault(PContextVarsContext self, Object key, Object def,
121+
@Cached PRaiseNode raise) {
118122
return getContextVar(self, key, def, raise);
119123
}
120124

121125
}
122126

123-
private static Object getContextVar(PContextVarsContext self, Object key, Object def, @Cached PRaiseNode raise) {
127+
private static Object getContextVar(PContextVarsContext self, Object key, Object def,
128+
@Cached PRaiseNode raise) {
124129
if (key instanceof PContextVar) {
125130
PContextVar ctxVar = (PContextVar) key;
126131
Object value = self.contextVarValues.lookup(key, ctxVar.getHash());
127132
if (value == null) {
128133
if (def == null) {
129-
throw raise.raise(PythonBuiltinClassType.KeyError, ErrorMessages.S, key);
134+
throw raise.raise(PythonBuiltinClassType.KeyError, new Object[]{key});
130135
} else {
131136
return def;
132137
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/contextvars/ContextVarBuiltins.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Object get(VirtualFrame frame, PContextVar self, Object def) {
9595
if (self.getDefault() != PContextVar.NO_DEFAULT) {
9696
return self.getDefault();
9797
}
98-
throw raise(LookupError, ErrorMessages.S, self);
98+
throw raise(LookupError, new Object[]{self});
9999
}
100100
}
101101

@@ -115,7 +115,8 @@ Object set(VirtualFrame frame, PContextVar self, Object value) {
115115
@GenerateNodeFactory
116116
public abstract static class ResetNode extends PythonBinaryBuiltinNode {
117117
@Specialization
118-
Object reset(PContextVar self, PContextVarsToken token, @Cached PRaiseNode raise) {
118+
Object reset(PContextVar self, PContextVarsToken token,
119+
@Cached PRaiseNode raise) {
119120
if (self == token.getVar()) {
120121
PythonContext.PythonThreadState threadState = getContext().getThreadState(getLanguage());
121122
if (token.getOldValue() == PContextVarsToken.MISSING) {
@@ -131,7 +132,8 @@ Object reset(PContextVar self, PContextVarsToken token, @Cached PRaiseNode raise
131132
}
132133

133134
@Specialization
134-
Object doError(PContextVar self, Object token, @Cached PRaiseNode raise) {
135+
Object doError(PContextVar self, Object token,
136+
@Cached PRaiseNode raise) {
135137
throw raise.raise(TypeError, ErrorMessages.INSTANCE_OF_TOKEN_EXPECTED, token);
136138
}
137139
}

0 commit comments

Comments
 (0)