Questions tagged [introspection]
A capability of some object-oriented programming languages to determine the type of an object at runtime.
1,007
questions
0
votes
1
answer
53
views
class hidden from module dictionary
I'm developing a code analysis tool for Python program.
I'm using introspection techniques to navigate into program structure.
Recently, I tested my tool on big packages like tkinter and matplotlib. ...
0
votes
3
answers
38
views
How to define a `Class` object type conforming to a protocol?
Consider the following Objective-C protocol declaration, which requires only class methods:
@protocol TDWMethoding<NSObject>
+ (void)foo;
+ (void)bar;
@end
Assuming I need to return an ...
1
vote
1
answer
71
views
Embed Python in Python?
I wrote a "compiler" PypTeX that converts an input file a.tex containing Hello @{3+4} to an ouput file a.pyptex containing Hello 7. I evaluate arbitrary Python fragments like @{3+4} using ...
0
votes
3
answers
47
views
C++: Within a Set or Map, can I determine that the KeyEqual predicate is equivalent to std::memcmp?
Simple examples:
Arithmetic scalars: the result of KeyEqual is equivalent to comparing bit patterns, so effectively std::memcmp.
Pointer to null-terminated string: the result of KeyEqual is not ...
1
vote
0
answers
51
views
python: how to find name of currently evaluating argument during function call
given the code example below: how can I get the name of argument corresponding to particular evaluation of function get_arg_val.
def do_sum(a, b, c):
return a + b + c
def get_arg_val():
print(...
0
votes
0
answers
24
views
How to determine the input object type of arguments to a graphql field in a resolver with graphql-js?
I'm writing a little something to record the usage of types and fields in a graphql server. It's working fine for output objects, but I am not yet able to figure out how to apply it to input arguments....
0
votes
0
answers
22
views
JWT Introspect with JOSE
I have inherited a node express application, which exposes rest APIs.
That system can get a jwt in the request and verify using jose.verify method.
Means that it verifies the jwks.
The task I have is ...
0
votes
0
answers
32
views
How to reload configuration in OpenIdDict?
I'm using instrospection (OpenIdDict v3.1.1) and have 1 application which can work in 2 modes:
standalone mode,
proxy mode - current instance (proxy) forwards request to second instance (master).
In ...
0
votes
1
answer
51
views
How to disable introspection and load a schema from a String in WunderGraph?
I am currently building a full stack application and having some performance issues with my service due to introspection. I would like to disable introspection for some services and rather load my ...
0
votes
0
answers
45
views
Postgraphile not exposing non public schema with introspection
When using Postgraphile with express, I can connect to my database, but when running the server via node dist/index.js:
Not working in index.js
const postgraphileOptions: PostGraphileOptions = {
...
1
vote
1
answer
36
views
How to determine whether a variable belongs to a class or an instance of the class in python?
class A:
def __init__(self):
self.one = 1
two = 2
a = A()
>>> A.__dict__
mappingproxy({'__dict__': <attribute '__dict__' of 'A' objects>,
'__doc__': None,...
0
votes
1
answer
108
views
Apollo-codegen introspection throws error
I have been working with apollo-codegen to introspect my schema in a proyect without problem and from one moment to other it started showing this error.
Command:
apollo-codegen introspect-schema https:...
0
votes
0
answers
73
views
Multiple OAuth2Introspection schemes to validate the token, want to allow execution if one the token validation check pass
I am trying to validate the token with multiple clients and if any of them passes the validation, I need to allow the execution of the request. Here's my code, it's working fine, but if one of them ...
0
votes
0
answers
20
views
How can I find names which were overwritten in the same Python namespace?
Suppose I have some Python code where the same identifier is used more than once-- for example,
def a():
pass
def b():
pass
def a():
pass
How can I introspect that code to find out about ...
-2
votes
1
answer
32
views
Print any object as a literal expression in python
I want to print objects, so that the result is a valid python expression and can be used to reconstruct equivalent value.
Let's call this function printexp
For example,
printexp(['a', 1+2, (True, {'f':...
0
votes
1
answer
140
views
Get property of a Kotlin reflected object with type Any
I have something like this
fun validate(obj1: Any) {
// Here I am getting the KClass of the object
val objKClass = obj1::class
// Here I am casting the object using KClass
val obj1Cast = ...
0
votes
1
answer
60
views
open auth introspection with okta authentication
I am trying to introspect token recieved from okta inside .net core api, but keep getting "token is not active".
With the setup you see bellow I am able to retrieve identity from token.(...
0
votes
0
answers
61
views
How to lookup properties with annotation in subclasses of abstract class?
I have an abstract class with 2 subclasses.
I have an annotation on some of the subclasses fields.
I want to create a function which can take the abstract class as argument, iterate over all the ...
1
vote
1
answer
87
views
How to check a class/type is iterable (uninstantiated)
I am inspecting type hints such as list[int] which is a GenericAlias.
If I get the origin using typing.get_origin(list[int]) or list[int].__origin__ it returns the class type list, as expected: <...
2
votes
1
answer
140
views
Is there a way to replace the mirror package for flutter?
this is flutter rsocket-dart code.
https://github.com/rsocket/rsocket-dart/blob/master/lib/route/reflection.dart
but, I cant't to use this library in flutter, because this package use 'dart:mirrors' ...
0
votes
0
answers
49
views
How to specify 0..1:0..1 relation in SQL so that Prisma db pull gets it right
I have two tables, MiniStore and Store; They are in a relationship that if a Store needs a position, it has to use MiniStore. Not every store has a reference to MiniStore, and there are many ...
1
vote
0
answers
275
views
How can we replace function parameters with string versions of the calling arguments?
Suppose that we have some function:
def funky_the_function(pos_zero, pos_one, *, default=None, sep = " "):
pass
Can you write a function-decorator which prints the function call?
That ...
0
votes
0
answers
55
views
Is there someway to convert a python stack frame into a unique number to use as a key to some container?
Consider the following sample of code:
import random
def inner(self):
frame_info = inspect.stack()[1]
value = random.uniform(0, 1)
I would like to convert frame_info into a dictionary key.
...
0
votes
0
answers
103
views
How can we print a nested tree of all of an object's attributes (recursivly call `dir()`)?
Suppose that we have a python object. I would like to print a tree describing all of that object's member variables and methods to a string.
Suppose that we have the following code:
class Klass:
...
0
votes
1
answer
82
views
Log to a file from Javascript code executed with no console window
Working on a Cinnamon applet (Example). These use Javascript interpreted by the cjs interpreter and run without a console window.
How can I log something to a file or to a console from within the code ...
2
votes
1
answer
72
views
Does Curity Introspection supports application/token-introspection+jwt?
Does anyone know if Curity supports application/token-introspection+jwt?
I am trying to implement https://curity.io/resources/learn/introspect-with-phantom-token/ and according to https://connect2id....
1
vote
1
answer
172
views
How to access a QPushButton object inside a QWidget?
For example in the code below:
>>> from PyQt5.QtWidgets import *
>>> import sys
>>> app = QApplication(sys.argv)
>>> widget = QWidget()
>>> layout = ...
4
votes
1
answer
181
views
Does Golang have something like C++'s decltype?
C++ has decltype(expr). You can declare an object of type of some other expression. For example:
decltype('c') a[4] will declare an array of 4 chars. This is a toy example, but this feature can be ...
2
votes
1
answer
56
views
Recursively introspecting at runtime the body of a lambda that is a specialisation of another lambda
I want to dynamically inspect the body of a lambda that specialises another lambda at runtime. This would need to happen recursively until there are no more "parent" lambdas.
What I mean by ...
1
vote
1
answer
75
views
How can I include the caller in debug logging from Python constructors?
I have a class C which is instantiated all over the place in a large program. C.__init__() contains debug logging, giving the parameters passed in to the new instance.
It's often useful for these log ...
0
votes
2
answers
137
views
Java: runtime reflection or type introspection?
Is the following code considered to be runtime reflection or is it type introspection?
Class c = java.util.ArrayList.class;
String className = c.getName();
I want to use this in the compilation phase,...
0
votes
1
answer
240
views
Why class constructor doesn't have attribute __code__?
I have simple python3 class:
class A:
def foo(self):
pass
print(A.foo.__code__.co_argcount)
print(A.__init__.__code__.co_argcount)
OUTPUT will be:
1
AttributeError: 'wrapper_descriptor' ...
1
vote
1
answer
132
views
c++ extract the template arugments of a function pointer
Is there a way to extract/introspect on templated function pointer to get its template argument types and size?
More generally speaking, what kind of Callables/Invocables in C++ are able to be ...
0
votes
0
answers
50
views
Is there a way I can access the attribute in an Attribute Error without parsing the string?
My python version is 3.6
I am trying to give a more helpful message on attribute errors in a CLI framework that I am building. I have the following code
print(cli_config.test_exension_config....
0
votes
2
answers
166
views
How do I get a function's full name and arguments as string from a list of function objects in Python?
As the title says, I am interested in a list of all functions inside my python module as string. So far I have a list of function objects with their possible arguments.
For example, with NumPy
from ...
2
votes
1
answer
2k
views
keycloak + Kong API Gateway
We are using keycloak to handle authentication (client/secret) in our API Gateway.
The Kong api service uses konnect-managed-plugin to refer to keycloak to authenicate client credentials and return a ...
0
votes
1
answer
593
views
validate opaque access token by Azure AD
Does Azure AD issue opaque access tokens or only JWT tokens?
If yes how do you validate opaque access tokens in that case? because there is no introspection end point?
1
vote
1
answer
513
views
Is it possible to get how many positional arguments does a function need in Python 3? [duplicate]
I am looking for a way to get how many positional arguments does a function need in Python 3.
Like this:
def a():pass # 0 positional arguments
def b(x):pass # 1 positional argument
def c(x=0):pass # 0 ...
1
vote
0
answers
36
views
Simple and reliable method to retrieve qualified name of the current function
I'd like to retrieve qualified name like function or class property __qualname__ for the current function. inspect.stack() provides only simple unqualified name.
So I'm looking for a trick to ...
1
vote
1
answer
100
views
Determine static method qualified name from within itself in python
I'm refactoring some code I wrote to work with an interactive TUI and I wish to use my class structure to create commands rather than explicitly typing out strings. Using __qualname__ would be very ...
0
votes
1
answer
362
views
Inserting a queried default value in a single GraphQL mutation
I am fairly new to GraphQL, using Hasura connected to a Postgres DB to expose some REST APIs.
I'd like to know if there is a way to insert a queried value in a single GraphQL mutation as a default ...
0
votes
0
answers
15
views
Is it possible to programmatically inspect the code of a function? [duplicate]
Assuming I have a (mathematical) function hyperbolic (it can also be a lambda function):
def hyperbolic(x):
return a*x + b
I know its possible to pass it in another function and get the name (and ...
0
votes
1
answer
157
views
Check if calling two function calls call the same function?
I am implementing a generic std::visit for std::variant and I need to optimise for use cases like the following:
std::variant<Base, Derived1, Derived2> x;
std::visit([] (Base&) {/* code */}, ...
0
votes
1
answer
48
views
Can I get a list of constructors (like with `Typeable`, `Data`), but based on type inference instead of a run-time representation of my type?
I had a hard time putting together the question. Let's try step by step:
I have a Haskell type class (that represents a keyboard layout fyi):
class Data key => Palantype key where
-- the ...
0
votes
1
answer
178
views
Runtime introspection in C++ - How does it work internally?
I am looking for on information how runtime introspection in C++ works.
From what I have found so far is that additional information will be stored as run-time type information (RTTI) for each type. I ...
0
votes
0
answers
158
views
Is it possible to check if a class calls a specific method?
I have code in which all classes that call a specific function need to be in a dictionary. Something like this:
import random
# Anna calls foo via bar
# Bob re-defines foo, but does not call foo
# ...
10
votes
2
answers
274
views
How to get a "help" functionality in REPL
When I use REPL, I sometimes need to look up how a function functions e.g. splice. I usually go to the documentation website. But I don't always have internet and it'd be good if I could write help(&...
0
votes
1
answer
315
views
Does Hasura generate Role-based introspection?
I want to build an admin tool based on a Hasura backend.
Different users will have different level of access based on roles.
Will I be able to do introspection per role and therefore know which fields ...
8
votes
2
answers
193
views
Find programmatically all classes, grammars, and roles in a Raku package
How can I find programmatically all the classes, grammars, and roles in a Raku package? (Specified with a string.)
I examined discussions/posts similar to the ones linked below, but the code I came up ...
7
votes
3
answers
278
views
Access callee/this in Raku map code/block
Is it possible to access the "callee" ("this") in Raku map code block and/or whatevercode?
E.g. if one wanted to calculate arithmetic mean
my $data = <1 10 0 7 2> ;
say $data....