
from __future__ import annotations
import codecs
from dataclasses import dataclass
import json

from flask import current_app


@dataclass(frozen=True)
class Country:
    name: str
    alpha2: str
    alpha3: str


def get_countries() -> list[Country]:
    """Load countries from JSON file."""
    reader = codecs.getreader('utf-8')

    path = 'services/country/resources/countries.json'
    with current_app.open_resource(path) as f:
        records = json.load(reader(f))

    return [Country(**record) for record in records]


def get_country_names() -> list[str]:
    """Return country names."""
    return [country.name for country in get_countries()]


from __future__ import annotations
from dataclasses import dataclass
import json

from flask import current_app


@dataclass(frozen=True)
class Country:
    name: str
    alpha2: str
    alpha3: str


def get_countries() -> list[Country]:
    """Load countries from JSON file."""
    path = 'services/country/resources/countries.json'
    with current_app.open_resource(path) as f:
        records = json.load(f)

    return [Country(**record) for record in records]


def get_country_names() -> list[str]:
    """Return country names."""
    return [country.name for country in get_countries()]

Remove unnecessary codec reader, fixes type issue
Remove unnecessary codec reader, fixes type issue

  
  from __future__ import annotations
- import codecs
  from dataclasses import dataclass
  import json
  
  from flask import current_app
  
  
  @dataclass(frozen=True)
  class Country:
      name: str
      alpha2: str
      alpha3: str
  
  
  def get_countries() -> list[Country]:
      """Load countries from JSON file."""
-     reader = codecs.getreader('utf-8')
- 
      path = 'services/country/resources/countries.json'
      with current_app.open_resource(path) as f:
-         records = json.load(reader(f))
+         records = json.load(f)
  
      return [Country(**record) for record in records]
  
  
  def get_country_names() -> list[str]:
      """Return country names."""
      return [country.name for country in get_countries()]
  
Remove unnecessary codec reader, fixes type issue
## Code Before:

from __future__ import annotations
import codecs
from dataclasses import dataclass
import json

from flask import current_app


@dataclass(frozen=True)
class Country:
    name: str
    alpha2: str
    alpha3: str


def get_countries() -> list[Country]:
    """Load countries from JSON file."""
    reader = codecs.getreader('utf-8')

    path = 'services/country/resources/countries.json'
    with current_app.open_resource(path) as f:
        records = json.load(reader(f))

    return [Country(**record) for record in records]


def get_country_names() -> list[str]:
    """Return country names."""
    return [country.name for country in get_countries()]

## Instruction:
Remove unnecessary codec reader, fixes type issue
## Code After:

from __future__ import annotations
from dataclasses import dataclass
import json

from flask import current_app


@dataclass(frozen=True)
class Country:
    name: str
    alpha2: str
    alpha3: str


def get_countries() -> list[Country]:
    """Load countries from JSON file."""
    path = 'services/country/resources/countries.json'
    with current_app.open_resource(path) as f:
        records = json.load(f)

    return [Country(**record) for record in records]


def get_country_names() -> list[str]:
    """Return country names."""
    return [country.name for country in get_countries()]
