Hm, strange. I can confirm your observed behaviour, I wrote a quick script to print both, merged and unmerged branches and get all branches no matter the filter set. Branches - python-gitlab v3.12.0 does not look like it supports a branch filter.
#!/usr/bin/env python
import gitlab
import os
import sys
GITLAB_SERVER = os.environ.get('GL_SERVER', 'https://gitlab.com')
# https://gitlab.com/dnsmichi/opsindev.news
PROJECT_ID = os.environ.get('GL_PROJECT_ID', 33298437)
GITLAB_TOKEN = os.environ.get('GL_TOKEN')
if not GITLAB_TOKEN:
print("Please set the GL_TOKEN env variable.")
sys.exit(1)
gl = gitlab.Gitlab(GITLAB_SERVER, private_token=GITLAB_TOKEN)
# Main
project = gl.projects.get(PROJECT_ID, lazy=False, pagination="keyset", order_by="updated_at", per_page=100)
# Get all merged branches
merged_branches_names = []
for branch in project.branches.list(merged=True, iterator=True):
merged_branches_names.append(branch.name)
print("Branches merged: {b}".format(b=", ".join(merged_branches_names)))
# Get un-merged branches
not_merged_branches_names = []
for branch in project.branches.list(merged=False, iterator=True):
not_merged_branches_names.append(branch.name)
print("Branches not merged: {b}".format(b=", ".join(not_merged_branches_names)))