Why can't you use an arraylist to store all the distance values along with a visited set?

I tried coming up with a solution, but can't figure out where I am going wrong:

class Solution(object):
def shortestDistance(self, maze, start, destination):
"""
:type maze: List[List[int]]
:type start: List[int]
:type destination: List[int]
:rtype: int
"""
def bfs(i,j,x,y,d):
while (0<=i+x<m and 0<=j+y<n) and maze[i+x][j+y]!=1:
d+=1
i+=x
j+=y
dis[i][j]=min(d,dis[i][j]) #can be visited when =2
q.append((i,j,dis[i][j]))
m,n=len(maze),len(maze[0])
dis=[[float("inf")]*n for _ in xrange(m)]
q=collections.deque([(start[0],start[1],0)])
seen=set()
ret=float("inf")
while q:
i,j,d=q.popleft()
if (i,j) in seen: continue
seen.add((i,j))
if [i,j]==destination:
ret=min(dis[i][j],d)
for x,y in (-1,0),(1,0),(0,-1),(0,1):
bfs(i,j,x,y,d)
ret=dis[destination[0]][destination[1]]
return ret if ret!=float("inf") else -1