Skip to content

Fix --setup file:/path/file.txt#10

Open
Julien00859 wants to merge 1 commit intowasi-master:mainfrom
Julien00859:Julien00859/setup
Open

Fix --setup file:/path/file.txt#10
Julien00859 wants to merge 1 commit intowasi-master:mainfrom
Julien00859:Julien00859/setup

Conversation

@Julien00859
Copy link

When --setup is given a file which is not in the current directory, it fails with an attribute error "None has no attribute group". The cause of the issue is that the regexp failed to match the file because '/' is not present in the pattern.

A solution to the problem would had been to add the / (and \ for Windows) to the pattern, but removing "file: " from "file:/path/file.py" is simpler.

When --setup is given a file which is not in the current directory, it
fails with an attribute error "None has no attribute group". The cause
of the issue is that the regexp failed to match the file because '/' is
not present in the pattern.

A solution to the problem would had been to add the / (and \ for
Windows) to the pattern, but removing "file: " from "file:/path/file.py"
is simpler.
@deepsource-io
Copy link
Contributor

deepsource-io bot commented Oct 14, 2025

Here's the code health analysis summary for commits 5dc29f8..2bde331. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Python LogoPython❌ Failure
❗ 1 occurence introduced
🎯 1 occurence resolved
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@Julien00859
Copy link
Author

First time contributing, I tried to look for unittests but it seems there are none. Also it seems to me that deepsource-io is complaining about a problem that is unrelated to this work.

@Julien00859
Copy link
Author

Btw, here is the complete traceback and steps to reproduce the problem:

$ uvx git+https://github.com/wasi-master/fastero --setup 'file:/tmp/ip.py' '(family_ip(ip4),family_ip(ip6),family_ip(dns4),family_ip(dns6))' '(family_dns(ip4),family_dns(ip6),family_dns(dns4),family_dns(dns6))'
    Updated https://github.com/wasi-master/fastero (5dc29f813cad6596f71a7015ae474c61fcbee0cd)
      Built fastero @ git+https://github.com/wasi-master/fastero@5dc29f813cad6596f71a7015ae474c61fcbee0cd
Installed 12 packages in 63ms
Traceback (most recent call last):
  File "/home/julien/.cache/uv/archive-v0/B5F6nLnX7CmCTIgG6wvH-/bin/fastero", line 12, in <module>
    sys.exit(app())
  File "/home/julien/.cache/uv/archive-v0/B5F6nLnX7CmCTIgG6wvH-/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/julien/.cache/uv/archive-v0/B5F6nLnX7CmCTIgG6wvH-/lib/python3.10/site-packages/rich_click/rich_command.py", line 19, in main
    return super().main(*args, standalone_mode=False, **kwargs)
  File "/home/julien/.cache/uv/archive-v0/B5F6nLnX7CmCTIgG6wvH-/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/julien/.cache/uv/archive-v0/B5F6nLnX7CmCTIgG6wvH-/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/julien/.cache/uv/archive-v0/B5F6nLnX7CmCTIgG6wvH-/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/julien/.cache/uv/archive-v0/B5F6nLnX7CmCTIgG6wvH-/lib/python3.10/site-packages/fastero/core.py", line 325, in app
    setup_file = setup_regex_match.group(1)
AttributeError: 'NoneType' object has no attribute 'group'

@Julien00859
Copy link
Author

And then the result on my branch:

~/P/fastero (Julien00859/setup|✔) $ uvx . --setup 'file:/tmp/ip.py' '(family_ip(ip4),family_ip(ip6),family_ip(dns4),family_ip(dns6))' '(family_dns(ip4),family_dns(ip6),family_dns(dns4),family_dns(dns6))'
╭───────────────────────────── Setup code ──────────────────────────────╮
│    1 import ipaddress                                                 │
│    2 import socket                                                    │
│    3                                                                  │
│    4 def family_ip(address):                                          │
│    5 │   try:                                                         │
│    6 │   │   ipaddress.IPv4Address(address)                           │
│    7 │   │   return socket.AF_INET                                    │
│    8 │   except ipaddress.AddressValueError:                          │
│    9 │   │   try:                                                     │
│   10 │   │   │   ipaddress.IPv6Address(address)                       │
│   11 │   │   │   return socket.AF_INET6                               │
│   12 │   │   except ipaddress.AddressValueError:                      │
│   13 │   │   │   return socket.getaddrinfo(address, 0,                │
│      type=socket.SOCK_STREAM)[0][0]                                   │
│   14                                                                  │
│   15 def family_dns(address):                                         │
│   16 │   return socket.getaddrinfo(address, 0,                        │
│      type=socket.SOCK_STREAM)[0][0]                                   │
│   17                                                                  │
│   18 ip4 = '127.0.0.1'                                                │
│   19 ip6 = '::1'                                                      │
│   20 dns4 = 'localhost'                                               │
│   21 dns6 = 'ip6-localhost'                                           │
│   22 bad = 'jexistepas'                                               │
│   23                                                                  │
╰───────────────────────────────────────────────────────────────────────╯
───────────────────────────────────────────────────────────────────────────────────────────────────────────── Benchmark started… ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
Benchmark 1: (family_ip(ip4),family_ip(ip6),family_ip(dns4),family_ip(dns6))
  Time  (mean ± σ):       65.68 µs ± 434.7 ns
  Range (min  … max):     65.18 µs … 66.52 µs    [runs: 45,000]
Benchmark 2: (family_dns(ip4),family_dns(ip6),family_dns(dns4),family_dns(dns6))
  Time  (mean ± σ):       45.75 µs ± 737.0 ns
  Range (min  … max):     44.84 µs … 46.99 µs    [runs: 65,000]

Summary:
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Bar Chart ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ (family_ip(ip4),family_ip(ip6),family_ip(dns4),family_ip(dns6))     [65.18 µs]: ▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆ ┃
┃ (family_dns(ip4),family_dns(ip6),family_dns(dns4),family_dns(dns6)) [44.84 µs]: ▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ (lower is better) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
  (family_dns(ip4),family_dns(ip6),family_dns(dns4),family_dns(dns6)) is the fastest.
    1.44 (1.45 … 1.42) times faster than (family_ip(ip4),family_ip(ip6),family_ip(dns4),family_ip(dns6))

@wasi-master
Copy link
Owner

Thanks, you did a great job. Seems good, will merge in the morning. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants