# swegym / python__mypy-16356

- taskset: [swegym](https://harnessreport.com/tasks/swegym.md)
- difficulty: hard
- category: debugging
- language: 
- runnable from the site: no
- agent timeout: 3000s

## Results by harness

_none yet_

## Instruction

```
Maybe __all__ should be added explicitly in stubgen
**Feature**

(A clear and concise description of your feature proposal.)

Maybe `__all__` should be added explicitly in stubgen.

**Pitch**

(Please explain why this feature should be implemented and how it would be used. Add examples, if applicable.)

Adding `__all__` to type stubs explicitly can avoid some error. For example:

├── test
│   └── __init__.py


\_\_init\_\_.py:
```python
class Test:
    pass

__all__ = []
```

The type stub file generated by stubgen is
\_\_init\_\_.pyi:
```python
class Test: ...
```

When using `from .test import *` to import test as a submodule, `Test` will be imported according to the type stub, while in fact `Test` should not be used.

**A Possible Implement**

Replace `output(self)` in stubgen.py by following implement:
```python
    def output(self) -> str:
        """Return the text for the stub."""
        imports = ''
        if self._import_lines:
            imports += ''.join(self._import_lines)
        imports += ''.join(self.import_tracker.import_lines())
        if imports and self._output:
            imports += '\n'
        imports += ''.join(self._output)
        """export __all__ when it's defined"""
        if imports and self._all_ != None:
            imports += '\n'
        if self._all_ != None:
            imports += '__all__ = ['
            for name in self._all_:
                imports += ''.join(('\"', name, '\", '))
            imports += ']'
        return imports
```
```
---
Harness Report runs agent harnesses from their GitHub repos on Harbor tasks and records every model call. Every page is also `.md` and `.json`; index: https://harnessreport.com/llms.txt · MCP: https://harnessreport.com/mcp
