<commit_before>package org.python.types;

public class Type extends org.python.types.Object implements org.python.Callable {
    public enum Origin {
        PLACEHOLDER,  // Dummy entry to resolve circular dependencies
        BUILTIN,      // A type provided as part of Python itself.
        PYTHON,       // A type defined in Python code
        JAVA,         // A type defined in Java
        EXTENSION     // A type defined in Python, extending a Java base class
    }

    public java.lang.String PYTHON_TYPE_NAME;
    private static java.util.Map<java.lang.Class, org.python.types.Type> known_types = new java.util.HashMap<java.lang.Class, org.python.types.Type>();
    public java.lang.reflect.Constructor constructor;
    public java.lang.Class klass;

    /**
     * Factory method to obtain Python classes from their Java counterparts
     */
    public static org.python.types.Type pythonType(java.lang.Class java_class) {
        // Look up the class in the known types table.
        org.python.types.Type python_type = known_types.get(java_class);
        if (python_type == null) {
            // If type isn't known, create and store a placeholder
            // so that recursive lookups have a termination condition.
            PlaceholderType placeholder = new PlaceholderType(java_class);
            known_types.put(java_class, placeholder);

            // Declare the type, and install it the known types list
            // (Replacing any placeholders)
            python_type = declarePythonType(java_class, null, null, null);

            // Since we have a freshly created type, resolve
            // any placeholders that referenced this type.
            // These will have been created as a consequence of
            // calling the constructor for this type.
            placeholder.resolve(python_type);

            // After object type is resolved, clean up subclasses that
            // reference the placeholder.
            if (java_class == org.python.types.Object.class) {
                java.util.List<org.python.Object> bases = new java.util.ArrayList<org.python.Object>();
                bases.add(python_type);
                for (org.python.types.Type type : known_types.values()) {
                    if (type.__dict__.get("__base__") == placeholder) {
                        type.__dict__.put("__base__", python_type);
                        type.__dict__.put("__bases__", new org.python.types.Tuple(bases));
                    }
                }
            }
        }
        // System.out.println("GOT TYPE " + java_class + " " + python_type.origin);
        return python_type;
    }

    public static org.python.types.Type pythonType(java.lang.String java_class_name) {
        try {
            return pythonType(java.lang.Thread.currentThread().getContextClassLoader().loadClass(java_class_name.replace("/", ".")));
        } catch (ClassNotFoundException e) {
            throw new org.python.exceptions.RuntimeError("Unknown Class " + java_class_name);
        }
    }

    public static org.python.types.Type declarePythonType(
            org.python.Object name,<commit_msg>Create overloaded pythonType method for builtin types<commit_after>package org.python.types;

public class Type extends org.python.types.Object implements org.python.Callable {
    public enum Origin {
        PLACEHOLDER,  // Dummy entry to resolve circular dependencies
        BUILTIN,      // A type provided as part of Python itself.
        PYTHON,       // A type defined in Python code
        JAVA,         // A type defined in Java
        EXTENSION     // A type defined in Python, extending a Java base class
    }

    public java.lang.String PYTHON_TYPE_NAME;
    private static java.util.Map<java.lang.Class, org.python.types.Type> known_types = new java.util.HashMap<java.lang.Class, org.python.types.Type>();
    public java.lang.reflect.Constructor constructor;
    public java.lang.Class klass;

    /**
     * Factory method to obtain Python classes from their Java counterparts
     */
    public static org.python.types.Type pythonType(java.lang.Class java_class) {
        // Look up the class in the known types table.
        org.python.types.Type python_type = known_types.get(java_class);
        if (python_type == null) {
            // If type isn't known, create and store a placeholder
            // so that recursive lookups have a termination condition.
            PlaceholderType placeholder = new PlaceholderType(java_class);
            known_types.put(java_class, placeholder);

            // Declare the type, and install it the known types list
            // (Replacing any placeholders)
            python_type = declarePythonType(java_class, null, null, null);

            // Since we have a freshly created type, resolve
            // any placeholders that referenced this type.
            // These will have been created as a consequence of
            // calling the constructor for this type.
            placeholder.resolve(python_type);

            // After object type is resolved, clean up subclasses that
            // reference the placeholder.
            if (java_class == org.python.types.Object.class) {
                java.util.List<org.python.Object> bases = new java.util.ArrayList<org.python.Object>();
                bases.add(python_type);
                for (org.python.types.Type type : known_types.values()) {
                    if (type.__dict__.get("__base__") == placeholder) {
                        type.__dict__.put("__base__", python_type);
                        type.__dict__.put("__bases__", new org.python.types.Tuple(bases));
                    }
                }
            }
        }
        // System.out.println("GOT TYPE " + java_class + " " + python_type.origin);
        return python_type;
    }

    public static org.python.types.Type pythonType(java.lang.String java_class_name) {
        try {
            return pythonType(java.lang.Thread.currentThread().getContextClassLoader().loadClass(java_class_name.replace("/", ".")));
        } catch (ClassNotFoundException e) {
            throw new org.python.exceptions.RuntimeError("Unknown Class " + java_class_name);
        }
    }

    public static org.python.types.Type pythonType(java.lang.Class java_class, java.lang.Class base_java_class) {
        org.python.types.Type python_type = pythonType(java_class);

        if (base_java_class != null) {
            org.python.types.Type base_python_type = known_types.get(base_java_class);
            java.util.List<org.python.Object> bases = new java.util.ArrayList<org.python.Object>();
            bases.add(base_python_type);
            python_type.__dict__.put("__base__", base_python_type);
            python_type.__dict__.put("__bases__", new org.python.types.Tuple(bases));
        }

        return python_type;
    }

    public static org.python.types.Type declarePythonType(
            org.python.Object name,
{'fraction_non_alphanumeric': 0.09438556287596678, 'fraction_numerical': 0.0, 'mean_word_length': 2.2120515179392823, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4639792', 'n_tokens_mistral': 1853, 'n_tokens_neox': 1802, 'n_words': 493}