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

Do not index sample programs that do not correspond to a valid project #69

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.x'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ newest changes first.
0.18.x
------

* v0.18.1
* Do not index sample programs that do not correspond to a valid project.

* v0.18.0
* Add ability to get information about untestable languages.
* Indicate support for python 3.11.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

MAJOR = 0
MINOR = 18
PATCH = 0
PATCH = 1

name = "subete"
version = f"{MAJOR}.{MINOR}"
Expand Down
11 changes: 9 additions & 2 deletions subete/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,11 @@ def _collect_sample_programs(self) -> Dict[str, SampleProgram]:
_, file_ext = os.path.splitext(file)
file_ext = file_ext.lower()
if file_ext not in (".md", "", ".yml"):
program = SampleProgram(self._path, file, self)
try:
program = SampleProgram(self._path, file, self)
except KeyError:
continue

sample_programs[program.project_name()] = program
logger.debug(f"New sample program collected: {program}")
sample_programs = dict(sorted(sample_programs.items()))
Expand Down Expand Up @@ -860,7 +864,10 @@ def __init__(self, path: str, file_name: str, language: LanguageCollection) -> N
self._path: str = path
self._file_name: str = file_name
self._language: LanguageCollection = language
self._project: Project = self._generate_project()
self._project: Optional[Project] = self._generate_project()
if not self._project:
raise KeyError(f"Project cannot be found for {file_name}")

self._sample_program_doc_url: str = self._generate_doc_url()
self._sample_program_issue_url: str = self._generate_issue_url()
self._line_count: int = len(self.code().splitlines())
Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration_for_bad_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_bad_repo_languages(bad_test_repo):


def test_bad_repo_total_programs(bad_test_repo):
assert bad_test_repo.total_programs() == 1
assert bad_test_repo.total_programs() == 0


def test_bad_repo_total_tests(bad_test_repo):
Expand Down